summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/shapes/Capsule.qml55
-rw-r--r--src/imports/shapes/Cube.qml48
-rw-r--r--src/imports/shapes/Cylinder.qml55
-rw-r--r--src/imports/shapes/Quad.qml48
-rw-r--r--src/imports/shapes/README.library_xml15
-rwxr-xr-xsrc/imports/shapes/README.plugins_types34
-rw-r--r--src/imports/shapes/Sphere.qml55
-rw-r--r--src/imports/shapes/Teapot.qml48
-rw-r--r--src/imports/shapes/capsulemesh.cpp352
-rw-r--r--src/imports/shapes/capsulemesh.h94
-rw-r--r--src/imports/shapes/capsulemesh_p.h83
-rw-r--r--src/imports/shapes/cube.h67
-rw-r--r--src/imports/shapes/cube.obj25
-rw-r--r--src/imports/shapes/cube.qdoc87
-rw-r--r--src/imports/shapes/cylindermesh.cpp348
-rw-r--r--src/imports/shapes/cylindermesh.h94
-rw-r--r--src/imports/shapes/cylindermesh_p.h85
-rw-r--r--src/imports/shapes/library.xml54
-rw-r--r--src/imports/shapes/line.cpp164
-rw-r--r--src/imports/shapes/line.h89
-rwxr-xr-xsrc/imports/shapes/plugins.qmltypes159
-rw-r--r--src/imports/shapes/point.cpp169
-rw-r--r--src/imports/shapes/point.h89
-rw-r--r--src/imports/shapes/qmldir7
-rw-r--r--src/imports/shapes/quad.obj12
-rw-r--r--src/imports/shapes/quad.qdoc87
-rw-r--r--src/imports/shapes/shapes.cpp72
-rw-r--r--src/imports/shapes/shapes.pro101
-rw-r--r--src/imports/shapes/spheremesh.cpp393
-rw-r--r--src/imports/shapes/spheremesh.h99
-rw-r--r--src/imports/shapes/spheremesh_p.h87
-rw-r--r--src/imports/shapes/teapot.bez340
-rw-r--r--src/imports/shapes/teapot.h67
-rw-r--r--src/imports/shapes/teapot.qdoc92
-rw-r--r--src/imports/threed/DefaultNavigator.qml181
-rw-r--r--src/imports/threed/README.library_xml15
-rwxr-xr-xsrc/imports/threed/README.plugins_types34
-rw-r--r--src/imports/threed/billboarditem3d.cpp170
-rw-r--r--src/imports/threed/billboarditem3d.h73
-rw-r--r--src/imports/threed/library.xml379
-rwxr-xr-xsrc/imports/threed/plugins.qmltypes499
-rw-r--r--src/imports/threed/qgraphicslookattransform.cpp517
-rw-r--r--src/imports/threed/qgraphicslookattransform.h94
-rw-r--r--src/imports/threed/qmldir1
-rw-r--r--src/imports/threed/qt3dnamespace.cpp100
-rw-r--r--src/imports/threed/qt3dnamespace.h78
-rw-r--r--src/imports/threed/scale3d.cpp74
-rw-r--r--src/imports/threed/scale3d.h80
-rw-r--r--src/imports/threed/shaderprogram.cpp979
-rw-r--r--src/imports/threed/shaderprogram.h95
-rw-r--r--src/imports/threed/shaderprogram_p.h152
-rw-r--r--src/imports/threed/skybox.cpp339
-rw-r--r--src/imports/threed/skybox.h111
-rw-r--r--src/imports/threed/threed.cpp125
-rw-r--r--src/imports/threed/threed.pro74
-rw-r--r--src/imports/threed/viewport.cpp1289
-rw-r--r--src/imports/threed/viewport.h158
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qpluginbase.pri21
-rw-r--r--src/plugins/qt_targets.pri4
-rw-r--r--src/plugins/sceneformats/3ds/3ds.pro50
-rw-r--r--src/plugins/sceneformats/3ds/README.txt55
-rw-r--r--src/plugins/sceneformats/3ds/main.cpp70
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsloader.cpp333
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsloader.h81
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsmesh.cpp755
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsmesh.h95
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsscene.cpp117
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsscene.h82
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsscenehandler.cpp255
-rw-r--r--src/plugins/sceneformats/3ds/qgl3dsscenehandler.h100
-rw-r--r--src/plugins/sceneformats/assimp/README.txt12
-rw-r--r--src/plugins/sceneformats/assimp/ailoaderiostream.cpp124
-rw-r--r--src/plugins/sceneformats/assimp/ailoaderiostream.h70
-rw-r--r--src/plugins/sceneformats/assimp/ailoaderiosystem.cpp160
-rw-r--r--src/plugins/sceneformats/assimp/ailoaderiosystem.h70
-rw-r--r--src/plugins/sceneformats/assimp/assimp.pro62
-rw-r--r--src/plugins/sceneformats/assimp/main.cpp100
-rw-r--r--src/plugins/sceneformats/assimp/qailoader.cpp541
-rw-r--r--src/plugins/sceneformats/assimp/qailoader.h95
-rw-r--r--src/plugins/sceneformats/assimp/qaimesh.cpp143
-rw-r--r--src/plugins/sceneformats/assimp/qaimesh.h72
-rw-r--r--src/plugins/sceneformats/assimp/qaiscene.cpp182
-rw-r--r--src/plugins/sceneformats/assimp/qaiscene.h85
-rw-r--r--src/plugins/sceneformats/assimp/qaiscenehandler.cpp453
-rw-r--r--src/plugins/sceneformats/assimp/qaiscenehandler.h111
-rw-r--r--src/plugins/sceneformats/bezier/bezier.pro38
-rw-r--r--src/plugins/sceneformats/bezier/main.cpp70
-rw-r--r--src/plugins/sceneformats/bezier/qglbezierscene.cpp71
-rw-r--r--src/plugins/sceneformats/bezier/qglbezierscene.h66
-rw-r--r--src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp197
-rw-r--r--src/plugins/sceneformats/bezier/qglbezierscenehandler.h58
-rw-r--r--src/plugins/sceneformats/obj/main.cpp78
-rw-r--r--src/plugins/sceneformats/obj/obj.pro37
-rw-r--r--src/plugins/sceneformats/obj/qglobjscene.cpp74
-rw-r--r--src/plugins/sceneformats/obj/qglobjscene.h74
-rw-r--r--src/plugins/sceneformats/obj/qglobjscenehandler.cpp470
-rw-r--r--src/plugins/sceneformats/obj/qglobjscenehandler.h76
-rw-r--r--src/plugins/sceneformats/sceneformats.pro7
-rw-r--r--src/private/private.pri3
-rw-r--r--src/private/qfactoryloader_p.h97
-rw-r--r--src/private/qglextensions_p.h884
-rw-r--r--src/quick3d/qdeclarativeeffect.cpp479
-rw-r--r--src/quick3d/qdeclarativeeffect.h125
-rw-r--r--src/quick3d/qdeclarativeitem3d.cpp1674
-rw-r--r--src/quick3d/qdeclarativeitem3d.h226
-rw-r--r--src/quick3d/qdeclarativemesh.cpp722
-rw-r--r--src/quick3d/qdeclarativemesh.h140
-rw-r--r--src/quick3d/qdeclarativeview3d.cpp88
-rw-r--r--src/quick3d/qdeclarativeview3d.h70
-rw-r--r--src/quick3d/qdeclarativeviewport.h72
-rw-r--r--src/quick3d/qt3dquickglobal.h73
-rw-r--r--src/quick3d/quick3d.pri18
-rw-r--r--src/quick3d/quick3d.pro123
-rw-r--r--src/scripts/LICENSE.LGPL.txt514
-rw-r--r--src/scripts/README39
-rwxr-xr-xsrc/scripts/build_mac_package.sh125
-rwxr-xr-xsrc/scripts/build_src_package.sh87
-rw-r--r--src/scripts/build_win_package.bat88
-rw-r--r--src/scripts/build_win_package.nsi218
-rwxr-xr-xsrc/scripts/filter-qmldump.pl65
-rw-r--r--src/scripts/mac-install.rtf13
-rw-r--r--src/scripts/mac_installer_background.pngbin89255 -> 0 bytes
-rw-r--r--src/scripts/qtquick3d.icobin51262 -> 0 bytes
-rw-r--r--src/scripts/win_installer_background.bmpbin206038 -> 0 bytes
-rw-r--r--src/scripts/windows-install.rtfbin486 -> 0 bytes
-rw-r--r--src/scripts/windows-install.txt10
-rw-r--r--src/src.pro4
-rw-r--r--src/threed/api/api.pri4
-rw-r--r--src/threed/api/gl-funcs.txt858
-rwxr-xr-xsrc/threed/api/gl-gen-funcs.pl484
-rw-r--r--src/threed/api/qopenglfunctions.cpp3690
-rw-r--r--src/threed/api/qopenglfunctions.h2292
-rw-r--r--src/threed/arrays/arrays.pri28
-rw-r--r--src/threed/arrays/qarray.cpp1022
-rw-r--r--src/threed/arrays/qarray.h1209
-rw-r--r--src/threed/arrays/qcolor4ub.cpp319
-rw-r--r--src/threed/arrays/qcolor4ub.h216
-rw-r--r--src/threed/arrays/qcustomdataarray.cpp909
-rw-r--r--src/threed/arrays/qcustomdataarray.h421
-rw-r--r--src/threed/arrays/qglattributedescription.cpp188
-rw-r--r--src/threed/arrays/qglattributedescription.h149
-rw-r--r--src/threed/arrays/qglattributeset.cpp207
-rw-r--r--src/threed/arrays/qglattributeset.h138
-rw-r--r--src/threed/arrays/qglattributevalue.cpp276
-rw-r--r--src/threed/arrays/qglattributevalue.h207
-rw-r--r--src/threed/arrays/qglindexbuffer.cpp777
-rw-r--r--src/threed/arrays/qglindexbuffer.h108
-rw-r--r--src/threed/arrays/qglvertexbundle.cpp495
-rw-r--r--src/threed/arrays/qglvertexbundle.h111
-rw-r--r--src/threed/arrays/qglvertexbundle_p.h216
-rw-r--r--src/threed/arrays/qvector2darray.cpp275
-rw-r--r--src/threed/arrays/qvector2darray.h124
-rw-r--r--src/threed/arrays/qvector3darray.cpp257
-rw-r--r--src/threed/arrays/qvector3darray.h116
-rw-r--r--src/threed/arrays/qvector4darray.cpp257
-rw-r--r--src/threed/arrays/qvector4darray.h118
-rw-r--r--src/threed/effects/effects.pri26
-rw-r--r--src/threed/effects/qglcolladafxeffect.cpp410
-rw-r--r--src/threed/effects/qglcolladafxeffect.h98
-rw-r--r--src/threed/effects/qglcolladafxeffect_p.h111
-rw-r--r--src/threed/effects/qglcolladafxeffectfactory.cpp1694
-rw-r--r--src/threed/effects/qglcolladafxeffectfactory.h218
-rw-r--r--src/threed/effects/qglcolladafxeffectloader.cpp190
-rw-r--r--src/threed/effects/qglcolladafxeffectloader.h73
-rw-r--r--src/threed/effects/qglflatcoloreffect.cpp350
-rw-r--r--src/threed/effects/qglflatcoloreffect_p.h99
-rw-r--r--src/threed/effects/qglflattextureeffect.cpp373
-rw-r--r--src/threed/effects/qglflattextureeffect_p.h98
-rw-r--r--src/threed/effects/qgllitmaterialeffect.cpp571
-rw-r--r--src/threed/effects/qgllitmaterialeffect_p.h85
-rw-r--r--src/threed/effects/qgllittextureeffect.cpp215
-rw-r--r--src/threed/effects/qgllittextureeffect_p.h86
-rw-r--r--src/threed/effects/qglshaderprogrameffect.cpp1131
-rw-r--r--src/threed/effects/qglshaderprogrameffect.h100
-rw-r--r--src/threed/geometry/geometry.pri28
-rw-r--r--src/threed/geometry/qgeometrydata.cpp2030
-rw-r--r--src/threed/geometry/qgeometrydata.h213
-rw-r--r--src/threed/geometry/qglbezierpatches.cpp815
-rw-r--r--src/threed/geometry/qglbezierpatches.h97
-rw-r--r--src/threed/geometry/qglbuilder.cpp1382
-rw-r--r--src/threed/geometry/qglbuilder.h140
-rw-r--r--src/threed/geometry/qglbuilder_p.h89
-rw-r--r--src/threed/geometry/qglcube.cpp198
-rw-r--r--src/threed/geometry/qglcube.h76
-rw-r--r--src/threed/geometry/qglcylinder.cpp445
-rw-r--r--src/threed/geometry/qglcylinder.h105
-rw-r--r--src/threed/geometry/qgldome.cpp281
-rw-r--r--src/threed/geometry/qgldome.h83
-rw-r--r--src/threed/geometry/qglmaterialcollection.cpp417
-rw-r--r--src/threed/geometry/qglmaterialcollection.h101
-rw-r--r--src/threed/geometry/qglsection.cpp700
-rw-r--r--src/threed/geometry/qglsection_p.h131
-rw-r--r--src/threed/geometry/qglsphere.cpp243
-rw-r--r--src/threed/geometry/qglsphere.h79
-rw-r--r--src/threed/geometry/qglteapot.cpp104
-rw-r--r--src/threed/geometry/qglteapot.h64
-rw-r--r--src/threed/geometry/qglteapot_data_p.h408
-rw-r--r--src/threed/geometry/qlogicalvertex.cpp420
-rw-r--r--src/threed/geometry/qlogicalvertex.h328
-rw-r--r--src/threed/geometry/qvector_utils_p.h110
-rw-r--r--src/threed/global/global.pri7
-rw-r--r--src/threed/global/qglnamespace.cpp290
-rw-r--r--src/threed/global/qglnamespace.h163
-rw-r--r--src/threed/global/qt3dglobal.h74
-rw-r--r--src/threed/graphicsview/graphicsview.pri21
-rw-r--r--src/threed/graphicsview/qglgraphicsviewportitem.cpp365
-rw-r--r--src/threed/graphicsview/qglgraphicsviewportitem.h100
-rw-r--r--src/threed/graphicsview/qgraphicsbillboardtransform.cpp258
-rw-r--r--src/threed/graphicsview/qgraphicsbillboardtransform.h82
-rw-r--r--src/threed/graphicsview/qgraphicsembedscene.cpp469
-rw-r--r--src/threed/graphicsview/qgraphicsembedscene.h88
-rw-r--r--src/threed/graphicsview/qgraphicsrotation3d.cpp274
-rw-r--r--src/threed/graphicsview/qgraphicsrotation3d.h91
-rw-r--r--src/threed/graphicsview/qgraphicsscale3d.cpp339
-rw-r--r--src/threed/graphicsview/qgraphicsscale3d.h88
-rw-r--r--src/threed/graphicsview/qgraphicstransform3d.cpp112
-rw-r--r--src/threed/graphicsview/qgraphicstransform3d.h71
-rw-r--r--src/threed/graphicsview/qgraphicstranslation3d.cpp233
-rw-r--r--src/threed/graphicsview/qgraphicstranslation3d.h87
-rw-r--r--src/threed/materials/materials.pri18
-rw-r--r--src/threed/materials/qglabstractmaterial.cpp239
-rw-r--r--src/threed/materials/qglabstractmaterial.h82
-rw-r--r--src/threed/materials/qglcolormaterial.cpp162
-rw-r--r--src/threed/materials/qglcolormaterial.h85
-rw-r--r--src/threed/materials/qglmaterial.cpp587
-rw-r--r--src/threed/materials/qglmaterial.h149
-rw-r--r--src/threed/materials/qglmaterial_p.h85
-rw-r--r--src/threed/materials/qgltwosidedmaterial.cpp259
-rw-r--r--src/threed/materials/qgltwosidedmaterial.h89
-rw-r--r--src/threed/math3d/math3d.pri12
-rw-r--r--src/threed/math3d/qbox3d.cpp690
-rw-r--r--src/threed/math3d/qbox3d.h218
-rw-r--r--src/threed/math3d/qplane3d.cpp302
-rw-r--r--src/threed/math3d/qplane3d.h161
-rw-r--r--src/threed/math3d/qray3d.cpp301
-rw-r--r--src/threed/math3d/qray3d.h164
-rw-r--r--src/threed/math3d/qsphere3d.cpp385
-rw-r--r--src/threed/math3d/qsphere3d.h164
-rw-r--r--src/threed/math3d/qtriangle3d.cpp379
-rw-r--r--src/threed/math3d/qtriangle3d.h182
-rw-r--r--src/threed/network/network.pri12
-rw-r--r--src/threed/network/qabstractdownloadmanager.cpp86
-rw-r--r--src/threed/network/qabstractdownloadmanager.h71
-rw-r--r--src/threed/network/qdownloadmanager.cpp214
-rw-r--r--src/threed/network/qdownloadmanager.h72
-rw-r--r--src/threed/network/qthreadeddownloadmanager.cpp386
-rw-r--r--src/threed/network/qthreadeddownloadmanager.h78
-rw-r--r--src/threed/network/qthreadeddownloadmanager_p.h114
-rw-r--r--src/threed/painting/painting.pri29
-rw-r--r--src/threed/painting/qglabstracteffect.cpp151
-rw-r--r--src/threed/painting/qglabstracteffect.h68
-rw-r--r--src/threed/painting/qglabstracteffect_p.h70
-rw-r--r--src/threed/painting/qglext.cpp99
-rw-r--r--src/threed/painting/qglext_p.h220
-rw-r--r--src/threed/painting/qgllightmodel.cpp291
-rw-r--r--src/threed/painting/qgllightmodel.h119
-rw-r--r--src/threed/painting/qgllightparameters.cpp828
-rw-r--r--src/threed/painting/qgllightparameters.h150
-rw-r--r--src/threed/painting/qglpainter.cpp2327
-rw-r--r--src/threed/painting/qglpainter.h225
-rw-r--r--src/threed/painting/qglpainter_p.h155
-rw-r--r--src/threed/painting/qglpickcolors.cpp1125
-rw-r--r--src/threed/painting/qglpickcolors_p.h66
-rw-r--r--src/threed/painting/qmatrix4x4stack.cpp380
-rw-r--r--src/threed/painting/qmatrix4x4stack.h105
-rw-r--r--src/threed/painting/qmatrix4x4stack_p.h77
-rw-r--r--src/threed/scene/qglabstractscene.cpp605
-rw-r--r--src/threed/scene/qglabstractscene.h113
-rw-r--r--src/threed/scene/qglpicknode.cpp215
-rw-r--r--src/threed/scene/qglpicknode.h82
-rw-r--r--src/threed/scene/qglrenderorder.cpp318
-rw-r--r--src/threed/scene/qglrenderorder.h203
-rw-r--r--src/threed/scene/qglrenderordercomparator.cpp164
-rw-r--r--src/threed/scene/qglrenderordercomparator.h69
-rw-r--r--src/threed/scene/qglrendersequencer.cpp369
-rw-r--r--src/threed/scene/qglrendersequencer.h87
-rw-r--r--src/threed/scene/qglrenderstate.cpp320
-rw-r--r--src/threed/scene/qglrenderstate.h105
-rw-r--r--src/threed/scene/qglsceneformatplugin.cpp316
-rw-r--r--src/threed/scene/qglsceneformatplugin.h122
-rw-r--r--src/threed/scene/qglscenenode.cpp1884
-rw-r--r--src/threed/scene/qglscenenode.h205
-rw-r--r--src/threed/scene/qglscenenode_p.h145
-rw-r--r--src/threed/scene/scene.pri19
-rw-r--r--src/threed/surfaces/qglabstractsurface.cpp318
-rw-r--r--src/threed/surfaces/qglabstractsurface.h95
-rw-r--r--src/threed/surfaces/qglcontextsurface.cpp70
-rw-r--r--src/threed/surfaces/qglcontextsurface_p.h85
-rw-r--r--src/threed/surfaces/qgldrawbuffersurface.cpp71
-rw-r--r--src/threed/surfaces/qgldrawbuffersurface_p.h86
-rw-r--r--src/threed/surfaces/qglframebufferobjectsurface.cpp209
-rw-r--r--src/threed/surfaces/qglframebufferobjectsurface.h86
-rw-r--r--src/threed/surfaces/qglmaskedsurface.cpp214
-rw-r--r--src/threed/surfaces/qglmaskedsurface_p.h105
-rw-r--r--src/threed/surfaces/qglpaintersurface.cpp72
-rw-r--r--src/threed/surfaces/qglpaintersurface_p.h86
-rw-r--r--src/threed/surfaces/qglpixelbuffersurface.cpp142
-rw-r--r--src/threed/surfaces/qglpixelbuffersurface.h79
-rw-r--r--src/threed/surfaces/qglsubsurface.cpp199
-rw-r--r--src/threed/surfaces/qglsubsurface.h84
-rw-r--r--src/threed/surfaces/qglwidgetsurface.cpp146
-rw-r--r--src/threed/surfaces/qglwidgetsurface.h80
-rw-r--r--src/threed/surfaces/surfaces.pri23
-rw-r--r--src/threed/textures/qareaallocator.cpp877
-rw-r--r--src/threed/textures/qareaallocator.h169
-rw-r--r--src/threed/textures/qglsharedresource.cpp236
-rw-r--r--src/threed/textures/qglsharedresource_p.h96
-rw-r--r--src/threed/textures/qgltexture2d.cpp805
-rw-r--r--src/threed/textures/qgltexture2d.h115
-rw-r--r--src/threed/textures/qgltexture2d_p.h126
-rw-r--r--src/threed/textures/qgltexturecube.cpp549
-rw-r--r--src/threed/textures/qgltexturecube.h112
-rw-r--r--src/threed/textures/qgltextureutils.cpp785
-rw-r--r--src/threed/textures/qgltextureutils_p.h164
-rw-r--r--src/threed/textures/textures.pri15
-rw-r--r--src/threed/threed.pri15
-rw-r--r--src/threed/threed.pro95
-rw-r--r--src/threed/viewing/qglcamera.cpp1328
-rw-r--r--src/threed/viewing/qglcamera.h184
-rw-r--r--src/threed/viewing/qglcameraanimation.cpp543
-rw-r--r--src/threed/viewing/qglcameraanimation.h116
-rw-r--r--src/threed/viewing/qglview.cpp1496
-rw-r--r--src/threed/viewing/qglview.h146
-rw-r--r--src/threed/viewing/viewing.pri12
326 files changed, 0 insertions, 82371 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
deleted file mode 100644
index 31886ee4..00000000
--- a/src/imports/imports.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += threed shapes
-CONFIG += ordered
diff --git a/src/imports/shapes/Capsule.qml b/src/imports/shapes/Capsule.qml
deleted file mode 100644
index 6997e76d..00000000
--- a/src/imports/shapes/Capsule.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-import Qt3D.Shapes 1.0
-
-Item3D {
- id: capsule
- property alias name: capsuleMesh.objectName
- property alias radius: capsuleMesh.radius
- property alias length: capsuleMesh.length
- property alias levelOfDetail: capsuleMesh.levelOfDetail
- mesh: CapsuleMesh {
- id: capsuleMesh
- }
-}
diff --git a/src/imports/shapes/Cube.qml b/src/imports/shapes/Cube.qml
deleted file mode 100644
index e60395a3..00000000
--- a/src/imports/shapes/Cube.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-
-Item3D {
- id: cube
- mesh: Mesh { source: "cube.obj" }
-}
diff --git a/src/imports/shapes/Cylinder.qml b/src/imports/shapes/Cylinder.qml
deleted file mode 100644
index 0323f425..00000000
--- a/src/imports/shapes/Cylinder.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-import Qt3D.Shapes 1.0
-
-Item3D {
- id: cylinder
- property alias name: cylinderMesh.objectName
- property alias radius: cylinderMesh.radius
- property alias length: cylinderMesh.length
- property alias levelOfDetail: cylinderMesh.levelOfDetail
- mesh: CylinderMesh {
- id: cylinderMesh
- }
-}
diff --git a/src/imports/shapes/Quad.qml b/src/imports/shapes/Quad.qml
deleted file mode 100644
index 5c636704..00000000
--- a/src/imports/shapes/Quad.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-
-Item3D {
- id: quad
- mesh: Mesh { source: "quad.obj" }
-}
diff --git a/src/imports/shapes/README.library_xml b/src/imports/shapes/README.library_xml
deleted file mode 100644
index 2f46d66d..00000000
--- a/src/imports/shapes/README.library_xml
+++ /dev/null
@@ -1,15 +0,0 @@
-The library.xml file is required to get syntax highlighting of Qt3D.Shapes
-plugin items in Qt Creator < version 2.2.
-
-The library.xml file is installed into the imports/Qt3D.Shapes tree along with
-the plugin and the qmldir file.
-
-When any of the elements - property names, class names or other exports
-- in the Qt3D.Shapes plugin are changed this file will need to be regenerated.
-
-To generate the library.xml file see the scripts/README file for a
-description of how to use the filter-qmldump.pl script.
-
-This is a less-than-optimal solution but as syntax discovery improves
-in Qt Creator better solutions should become available at which time
-this temporary script and syntax file may be deprecated.
diff --git a/src/imports/shapes/README.plugins_types b/src/imports/shapes/README.plugins_types
deleted file mode 100755
index ff41ea12..00000000
--- a/src/imports/shapes/README.plugins_types
+++ /dev/null
@@ -1,34 +0,0 @@
-The plugins.qmltypes file is required to get syntax highlighting of Qt3D.Shapes
-plugin items inside Qt Creator 2.2 and later.
-
-To support earlier versions of Qt Creator the library.xml file is used.
-
-The plugins.qmltypes file is installed into the imports/Qt3D.Shapes tree along
-with the plugin and the qmldir file.
-
-When any of the elements - property names, class names or other exports
-- in the Qt3D.Shapes plugin are changed this file will need to be regenerated.
-
-To generate the plugins.qmltypes, you first need a qmldump binary generated from
-sources shipped with Qt Creator 2.2 or greater. On Mac these are inside the app
-bundle, other platforms vary. If all else fails get the sources from the Qt
-Creator repo.
-
-To build qmldump you need access to private headers, so therefore it must be
-built against a source build of Qt. On Mac it is helpful to build qmldump with
-"qmake CONFIG-=app_bundle" so that you get a regular command-line binary.
-
-Once you finally have a viable qmldump binary:
-
-./qmldump Qt3D.Shapes 1.0 $QTDIR/imports > plugins.qmltypes
-
-...where $QTDIR points to the root of the Qt where Qt3D is installed.
-
-If you get a usage error like:
-
-Usage: qmldump [plugin/import/path plugin.uri]
-
-...then the version of qmldump source you used was not for Qt Creator > 2.2 -
-you somehow have the earlier version qmldump sources.
-
-You do not need to use the filter-qmldump.pl script.
diff --git a/src/imports/shapes/Sphere.qml b/src/imports/shapes/Sphere.qml
deleted file mode 100644
index 15a9f020..00000000
--- a/src/imports/shapes/Sphere.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-import Qt3D.Shapes 1.0
-
-Item3D {
- id: sphere
- property alias name: sphereMesh.objectName
- property alias radius: sphereMesh.radius
- property alias levelOfDetail: sphereMesh.levelOfDetail
- property alias axis: sphereMesh.axis
- mesh: SphereMesh {
- id: sphereMesh
- }
-}
diff --git a/src/imports/shapes/Teapot.qml b/src/imports/shapes/Teapot.qml
deleted file mode 100644
index 3c4df17a..00000000
--- a/src/imports/shapes/Teapot.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 1.0
-import Qt3D 1.0
-
-Item3D {
- id: teapot
- mesh: Mesh { source: "teapot.bez" }
-}
diff --git a/src/imports/shapes/capsulemesh.cpp b/src/imports/shapes/capsulemesh.cpp
deleted file mode 100644
index 5b0c068d..00000000
--- a/src/imports/shapes/capsulemesh.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "capsulemesh.h"
-#include "qglbuilder.h"
-#include "qglcylinder.h"
-#include "qgldome.h"
-#include "qglabstractscene.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass CapsuleMesh CapsuleMesh
- \brief The CapsuleMesh item represents a simple capsule in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The CapsuleMesh element in QML provides a simple way to create a capsule
- object, usually for testing material effects. For example,
- the following QML code displays a green capsule of with a uniform
- diameter of 0.5, and a length of 3.0, centered vertically on the
- origin:
-
- \code
- Item3D {
- mesh: CapsuleMesh {
- radius: 0.5
- length: 3.0
- }
- effect: Effect {
- color: "#aaca00"
- }
- }
- \endcode
-
- The CapsuleMesh element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The capsule shape can have differing levels of detail, allowing
- for additional slices and layers to be drawn if more detailed meshes
- are required.
-
- Note that the length of the capsule should always exceed its
- diameter to be considered valid.
-
- To display the capsule mesh you can create your own Item3D as shown
- above, or use the convenience Capsule QML Component.
-
- \code
- Capsule {
- radius: 0.5
- length: 3.0
- effect: Effect {
- color: "#aaca00"
- }
- }
- \endcode
-
- \section1 Performance Hints for Larger Scenes
-
- The convenience Capsule QML component will create a new mesh each
- time is instantiated.
-
- If you have a scene with a number of similar capsules use your own
- Item3D elements to all refer to the same mesh. See the Performance
- Hints section of the SphereMesh documentation for more details on
- this important technique.
-
- \section1 Performance Hints for Animation
-
- Because of the need to maintain the relative proportions of the
- cylinders components, the length and radius are implemented directly
- in the construction of the mesh. This differs from the approach
- used in the SphereMesh where a scale is used.
-
- For this reason avoid animating the length and radius properties
- of a CapsuleMesh, as it will give poor results due to the mesh
- being recreated every frame.
-
- Since the capules components are created with named sections in
- the mesh, one approach would be to individually apply scales to
- these sections using the meshNode property. This is an
- advanced topic, and future tutorials may cover it in more depth.
-
- \sa Item3D, SphereMesh
-*/
-
-CapsuleMeshPrivate::CapsuleMeshPrivate()
- : topNode(new QGLSceneNode)
- , currentCapsule(0)
- , radius(1.0f)
- , length(1.0f)
- , lod(5)
- , sceneSet(false)
-{
- topNode->setObjectName("CapsuleMesh");
-}
-
-CapsuleMeshPrivate::~CapsuleMeshPrivate()
-{
- topNode->removeNode(currentCapsule);
- delete topNode;
- QList<QGLSceneNode*> lods = lodGeometry.values();
- qDeleteAll(lods);
-}
-
-class CapsuleScene : public QGLAbstractScene
-{
-public:
- explicit CapsuleScene(QGLSceneNode *s) : m_s(s) {}
- ~CapsuleScene() {}
- QList<QObject *> objects() const
- {
- QList<QObject *> s;
- s.append(m_s);
- return s;
- }
- QGLSceneNode *mainNode() const
- {
- return m_s;
- }
-private:
- QGLSceneNode *m_s;
-};
-
-/*!
- \internal
-*/
-CapsuleMesh::CapsuleMesh(QObject *parent)
- : QDeclarativeMesh(parent)
- , d_ptr(new CapsuleMeshPrivate)
-{
-}
-
-/*!
- \qmlproperty real CapsuleMesh::radius
-
- This property defines the radius of the capsule.
- The default value is 1.
-*/
-qreal CapsuleMesh::radius() const
-{
- Q_D(const CapsuleMesh);
- return d->radius;
-}
-
-void CapsuleMesh::setRadius(qreal radius)
-{
- Q_D(CapsuleMesh);
- if (qFuzzyCompare(radius, 1))
- radius = 1.0f;
- if (d->radius != radius) {
- d->radius = radius;
- createGeometry();
- emit radiusChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty real CapsuleMesh::length
-
- This property defines the length of the capsule.
- The default value is 1.
-*/
-qreal CapsuleMesh::length() const
-{
- Q_D(const CapsuleMesh);
- return d->length;
-}
-
-void CapsuleMesh::setLength(qreal length)
-{
- Q_D(CapsuleMesh);
- if (qFuzzyCompare(length, 1))
- length = 1.0f;
- if (d->length != length) {
- d->length = length;
- createGeometry();
- emit lengthChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty int CapsuleMesh::levelOfDetail
-
- This property defines the level of detail, between 1 and 10,
- which controls the number of slices and layers that are used
- to generate the capsule's mesh.
-
- Values outside the range 1 to 10 will be clamped to the range
- when the capsule is generated.
-
- The exact number of facets generated is consistent with the
- level of detail as specified in the Cylinder and Sphere
- objects.
-
- \sa Sphere, Cylinder
-*/
-int CapsuleMesh::levelOfDetail() const
-{
- Q_D(const CapsuleMesh);
- return d->lod;
-}
-
-void CapsuleMesh::setLevelOfDetail(int lod)
-{
- Q_D(CapsuleMesh);
- lod = qBound(1, lod, 10);
- if (d->lod != lod) {
- d->lod = lod;
- createGeometry();
- emit levelOfDetailChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \internal
-*/
-void CapsuleMesh::draw(QGLPainter *painter, int branchId)
-{
- Q_D(CapsuleMesh);
- if (!d->currentCapsule)
- createGeometry();
- QDeclarativeMesh::draw(painter, branchId);
-}
-
-/*!
- \internal
-*/
-void CapsuleMesh::createGeometry()
-{
- Q_D(CapsuleMesh);
-
- // Create a new geometry node for this level of detail if necessary.
- QGLSceneNode *geometry = d->lodGeometry.value(d->lod, 0);
- if (!geometry) {
- QGLBuilder builder;
-
- // For the cylinder
- int facets = 4 * 1 << d->lod;
- int layers = 1 << d->lod;
-
- // For the spheres
- int divisions = d->lod;
-
- // Sanity check - the height of the capsule must not be less than its
- // diameter. A minimal capsule is a sphere - where diameter == height.
- if (d->length < 2.0 * d->radius)
- {
- qWarning() << "Length of capsule must exceed its diameter"
- << " - correcting height.";
- d->length = 2 * d->radius;
- }
-
- qreal diameter = d->radius+d->radius;
- qreal cylinderHeight = d->length - diameter;
- qreal offset = cylinderHeight/2.0;
-
- builder << QGL::Faceted;
- QGLSceneNode *s = 0;
- s = builder.newNode();
- s->setObjectName("Cylinder");
- builder << QGLCylinder(diameter, diameter, cylinderHeight,
- facets, layers, false, false);
- QMatrix4x4 translateMatrix;
- translateMatrix.translate(0, 0, -offset);
- builder.currentNode()->setLocalTransform(translateMatrix);
-
- s = builder.newNode();
- s->setObjectName("LeftEndCap");
- builder << QGLDome(diameter, divisions, false);
- translateMatrix.setToIdentity();
- translateMatrix.rotate(180, 0, 1,0);
- translateMatrix.translate(0, 0, offset);
- builder.currentNode()->setLocalTransform(translateMatrix);
-
- s = builder.newNode();
- s->setObjectName("RightEndCap");
- builder << QGLDome(diameter, divisions, false);
- translateMatrix.setToIdentity();
- translateMatrix.translate(0, 0, offset);
- builder.currentNode()->setLocalTransform(translateMatrix);
-
- geometry = builder.finalizedSceneNode();
-
- d->lodGeometry.insert(d->lod, geometry);
- }
- Q_ASSERT_X(geometry != 0, Q_FUNC_INFO, "Could not create/find geometry!");
- if (d->currentCapsule != geometry)
- {
- if (d->currentCapsule)
- d->topNode->removeNode(d->currentCapsule);
- d->topNode->addNode(geometry);
- d->currentCapsule = geometry;
- }
-
- if (!d->sceneSet)
- {
- setScene(new CapsuleScene(d->topNode));
- d->sceneSet = true;
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/imports/shapes/capsulemesh.h b/src/imports/shapes/capsulemesh.h
deleted file mode 100644
index 3076f6ab..00000000
--- a/src/imports/shapes/capsulemesh.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CAPSULE_H
-#define CAPSULE_H
-
-#include "qdeclarativemesh.h"
-#include "capsulemesh_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class CapsuleMesh : public QDeclarativeMesh
-{
- Q_OBJECT
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
- Q_PROPERTY(qreal length READ length WRITE setLength NOTIFY lengthChanged)
- Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged)
-
-public:
- explicit CapsuleMesh(QObject *parent = 0);
- ~CapsuleMesh() {}
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- qreal length() const;
- void setLength(qreal length);
-
- int levelOfDetail() const;
- void setLevelOfDetail(int lod);
-
- void draw(QGLPainter *painter, int branchId);
-
-Q_SIGNALS:
- void radiusChanged();
- void lengthChanged();
- void levelOfDetailChanged();
-
-private:
- void createGeometry();
-
- Q_DISABLE_COPY(CapsuleMesh)
- Q_DECLARE_PRIVATE(CapsuleMesh)
-
- QScopedPointer<CapsuleMeshPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(CapsuleMesh)
-
-QT_END_HEADER
-
-#endif // CAPSULE_H
diff --git a/src/imports/shapes/capsulemesh_p.h b/src/imports/shapes/capsulemesh_p.h
deleted file mode 100644
index 2cff15fd..00000000
--- a/src/imports/shapes/capsulemesh_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CAPSULEMESH_P_H
-#define CAPSULEMESH_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.
-//
-
-#include <QtCore/QMap>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLSceneNode;
-
-class CapsuleMeshPrivate
-{
-public:
- CapsuleMeshPrivate();
- ~CapsuleMeshPrivate();
-
- QMap<int, QGLSceneNode *> lodGeometry;
- QGLSceneNode *topNode;
- QGLSceneNode *currentCapsule;
- qreal radius;
- qreal length;
- int lod;
- bool sceneSet;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // CAPSULEMESH_P_H
diff --git a/src/imports/shapes/cube.h b/src/imports/shapes/cube.h
deleted file mode 100644
index 73d72127..00000000
--- a/src/imports/shapes/cube.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CUBE_H
-#define CUBE_H
-
-// This is a dummy header for defining the interface of "Cube.qml" to qdoc.
-
-#include "item3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Cube : public Item3D
-{
- Q_OBJECT
-public:
- Cube(QObject *parent = 0) : Item3D(parent) {}
- ~Cube() {}
-};
-
-QML_DECLARE_TYPE(Cube)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/imports/shapes/cube.obj b/src/imports/shapes/cube.obj
deleted file mode 100644
index 7e0c3e0a..00000000
--- a/src/imports/shapes/cube.obj
+++ /dev/null
@@ -1,25 +0,0 @@
-s 0
-v -0.5 -0.5 -0.5
-v -0.5 -0.5 0.5
-v -0.5 0.5 0.5
-v -0.5 0.5 -0.5
-v 0.5 -0.5 -0.5
-v 0.5 -0.5 0.5
-v 0.5 0.5 0.5
-v 0.5 0.5 -0.5
-vn -1.0 0.0 0.0
-vn 0.0 1.0 0.0
-vn 1.0 0.0 0.0
-vn 0.0 -1.0 0.0
-vn 0.0 0.0 1.0
-vn 0.0 0.0 -1.0
-vt 1.0 0.0
-vt 1.0 1.0
-vt 0.0 1.0
-vt 0.0 0.0
-f 1/4/1 2/1/1 3/2/1 4/3/1
-f 4/3/2 3/4/2 7/1/2 8/2/2
-f 8/2/3 7/3/3 6/4/3 5/1/3
-f 5/1/4 6/2/4 2/3/4 1/4/4
-f 6/1/5 7/2/5 3/3/5 2/4/5
-f 8/3/6 5/4/6 1/1/6 4/2/6
diff --git a/src/imports/shapes/cube.qdoc b/src/imports/shapes/cube.qdoc
deleted file mode 100644
index db6782b5..00000000
--- a/src/imports/shapes/cube.qdoc
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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$
-**
-****************************************************************************/
-
-/*!
- \qmlclass Cube Cube
- \brief The Cube item represents a simple cube in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The Cube element in QML provides a simple way to create a cube
- object, usually for testing material effects. For example,
- the following QML code displays a cube of size 1.5, centered
- on the origin and covered in the Qt logo texture:
-
- \code
- Cube {
- scale: 1.5
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- }
- }
- \endcode
-
- The Cube element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The cube can be moved from the origin by specifying the
- Item3D::position property:
-
- \code
- Cube {
- scale: 1.5
- position: Qt.vector3d(1, 0, 5)
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- }
- }
- \endcode
-
- \sa Item3D
-*/
diff --git a/src/imports/shapes/cylindermesh.cpp b/src/imports/shapes/cylindermesh.cpp
deleted file mode 100644
index ee814009..00000000
--- a/src/imports/shapes/cylindermesh.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "cylindermesh.h"
-#include "qglbuilder.h"
-#include "qglcylinder.h"
-#include "qgraphicsscale3d.h"
-#include "qglabstractscene.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass CylinderMesh CylinderMesh
- \brief The CylinderMesh item represents a simple cylinder in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The CylinderMesh element in QML provides a way to create a simple cylinder
- object, usually for testing material effects. For example, the
- following QML code displays a green cylinder of with a uniform
- diameter of 0.5, and a length of 3.0, centered with its base on the
- origin:
-
- \code
- Item3D {
- mesh: CylinderMesh {
- radius: 0.5
- length: 3.0
- }
- effect: Effect {
- color: "#aaca00"
- }
- }
- \endcode
-
- The CylinderMesh element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The cylinder shape can have differing levels of detail, allowing
- for additional slices and layers to be drawn if more detailed meshes
- are required.
-
- To display the cylinder mesh you can create your own Item3D as shown
- above, or use the convenience Cylinder QML Component.
-
- \code
- Cylinder {
- radius: 0.5
- length: 3.0
- effect: Effect {
- color: "#aaca00"
- }
- }
- \endcode
-
- \section1 Performance Hints for Larger Scenes
-
- The convenience Cylinder QML component will create a new mesh each
- time is instantiated.
-
- If you have a scene with a number of similar capsules use your own
- Item3D elements to all refer to the same mesh. See the Performance
- Hints section of the SphereMesh documentation for more details on
- this important technique.
-
- \section1 Performance Hints for Animation
-
- Some support for animation of the CylinderMesh properties is provided
- by utilizing a QGraphicsScale3D to implement the length & radius
- properties, and by caching levels of detail.
-
- So within limits animation of these items should provide reasonable
- results. Be aware that on constrained devices animation of the
- level of detail for many cylinders could cause problems with memory
- usage due to the caching.
-
- \sa Item3D, SphereMesh
-*/
-
-CylinderMeshPrivate::CylinderMeshPrivate()
- : topNode(new QGLSceneNode)
- , currentCylinder(0)
- , scale(0)
- , radius(1.0f)
- , length(1.0f)
- , lod(5)
- , sceneSet(false)
-{
- topNode->setObjectName("CylinderMesh");
-}
-
-CylinderMeshPrivate::~CylinderMeshPrivate()
-{
- topNode->removeNode(currentCylinder);
- delete topNode;
- QList<QGLSceneNode*> lods = lodGeometry.values();
- qDeleteAll(lods);
-}
-
-class CylinderScene : public QGLAbstractScene
-{
-public:
- explicit CylinderScene(QGLSceneNode *s) : m_s(s) {}
- ~CylinderScene() {}
- QList<QObject *> objects() const
- {
- QList<QObject *> s;
- s.append(m_s);
- return s;
- }
- QGLSceneNode *mainNode() const
- {
- return m_s;
- }
-private:
- QGLSceneNode *m_s;
-};
-
-/*!
- \internal
-*/
-CylinderMesh::CylinderMesh(QObject *parent)
- : QDeclarativeMesh(parent)
- , d_ptr(new CylinderMeshPrivate)
-{
-}
-
-/*!
- \qmlproperty real CylinderMesh::radius
-
- This property defines the radius of the cylinder.
- The default value is 1.
-*/
-qreal CylinderMesh::radius() const
-{
- Q_D(const CylinderMesh);
- return d->radius;
-}
-
-void CylinderMesh::setRadius(qreal radius)
-{
- Q_D(CylinderMesh);
- if (qFuzzyCompare(radius, 1))
- radius = 1.0f;
- if (d->radius != radius) {
- d->radius = radius;
- createGeometry();
- emit radiusChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty real CylinderMesh::length
-
- This property defines the length of the cylinder.
- The default value is 1.
-*/
-qreal CylinderMesh::length() const
-{
- Q_D(const CylinderMesh);
- return d->length;
-}
-
-void CylinderMesh::setLength(qreal length)
-{
- Q_D(CylinderMesh);
- if (qFuzzyCompare(length, 1))
- length = 1.0f;
- if (d->length != length) {
- d->length = length;
- createGeometry();
- emit lengthChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty int CylinderMesh::levelOfDetail
-
- This property defines the level of detail, between 1 and 10,
- which controls the number of slices and layers that are used
- to generate the cylinder's mesh.
-
- Values outside the range 1 to 10 will be clamped to the range
- when the cylinder is generated.
-
- The default value is 1, which produces a cylinder with 8
- slices/facets and 2 layers. Each successive increase in this
- level of detail doubles the number of facets and layers. The
- following table provides information for these level of detail
- values
-
- \table
- \header \o Level of Detail \o Facets \o Layers
- \row \o 1 \o 8 \o 2
- \row \o 2 \o 16 \o 4
- \row \o 3 \o 32 \o 8
- \row \o 4 \o 64 \o 16
- \row \o 5 \o 128 \o 32
- \row \o 6 \o 256 \o 64
- \row \o 7 \o 512 \o 128
- \row \o 8 \o 1024 \o 256
- \row \o 9 \o 2048 \o 512
- \row \o 10 \o 4096 \o 1024
- \endtable
-*/
-int CylinderMesh::levelOfDetail() const
-{
- Q_D(const CylinderMesh);
- return d->lod;
-}
-
-void CylinderMesh::setLevelOfDetail(int lod)
-{
- Q_D(CylinderMesh);
- lod = qBound(1, lod, 10);
- if (d->lod != lod) {
- d->lod = lod;
- createGeometry();
- emit levelOfDetailChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \internal
-*/
-void CylinderMesh::draw(QGLPainter *painter, int branchId)
-{
- Q_D(CylinderMesh);
- if (!d->currentCylinder)
- createGeometry();
- QDeclarativeMesh::draw(painter, branchId);
-}
-
-/*!
- \internal
-*/
-void CylinderMesh::createGeometry()
-{
- Q_D(CylinderMesh);
-
- int facets = 4 * 1 << d->lod;
- int layers = 1 << d->lod;
-
- // Create a new geometry node for this level of detail if necessary.
- QGLSceneNode *geometry = d->lodGeometry.value(d->lod, 0);
- if (!geometry) {
- QGLBuilder builder;
- builder << QGL::Faceted << QGLCylinder(2.0, 2.0, 1.0, facets,
- layers, true, true);
- geometry = builder.finalizedSceneNode();
- geometry->setParent(this);
- d->lodGeometry.insert(d->lod, geometry);
- }
- Q_ASSERT_X(geometry != 0, Q_FUNC_INFO, "Could not create/find geometry!");
- if (d->currentCylinder != geometry)
- {
- if (d->currentCylinder)
- d->topNode->removeNode(d->currentCylinder);
- d->topNode->addNode(geometry);
- d->currentCylinder = geometry;
- }
-
- // Set the length as a scale on the modelview transformation.
- // This way, we don't have to regenerate the geometry every
- // frame if the height is being animated.
- //
- // We could do the scales separately if either height or radius
- // were != 1.0f, but the same amount of maths is required, so
- // we can just scale appropriately on the axes.
- if (d->radius != 1.0f || d->length != 1.0)
- {
- if (!d->scale)
- {
- d->scale = new QGraphicsScale3D(d->topNode);
- d->topNode->addTransform(d->scale);
- }
- if (d->scale->scale().x() != d->radius ||
- d->scale->scale().z() != d->length)
- {
- d->scale->setScale(QVector3D(d->radius, d->radius, d->length));
- }
- }
- else
- {
- // If there is already a scale set it to be the identity scale.
- // This case is optimised for in QGraphicsScale. Removing it from
- // the transform list is too expensive, especially if the size is
- // being animated, and the next frame will recreate it.
- if (d->scale)
- d->scale->setScale(QVector3D(1, 1, 1));
- }
-
- if (!d->sceneSet)
- {
- setScene(new CylinderScene(d->topNode));
- d->sceneSet = true;
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/imports/shapes/cylindermesh.h b/src/imports/shapes/cylindermesh.h
deleted file mode 100644
index bfdc46f3..00000000
--- a/src/imports/shapes/cylindermesh.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CYLINDER_H
-#define CYLINDER_H
-
-#include "qdeclarativemesh.h"
-#include "cylindermesh_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class CylinderMesh : public QDeclarativeMesh
-{
- Q_OBJECT
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
- Q_PROPERTY(qreal length READ length WRITE setLength NOTIFY lengthChanged)
- Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged)
-
-public:
- explicit CylinderMesh(QObject *parent = 0);
- ~CylinderMesh() {}
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- qreal length() const;
- void setLength(qreal length);
-
- int levelOfDetail() const;
- void setLevelOfDetail(int lod);
-
- void draw(QGLPainter *painter, int branchId);
-
-Q_SIGNALS:
- void radiusChanged();
- void lengthChanged();
- void levelOfDetailChanged();
-
-private:
- void createGeometry();
-
- Q_DISABLE_COPY(CylinderMesh)
- Q_DECLARE_PRIVATE(CylinderMesh)
-
- QScopedPointer<CylinderMeshPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(CylinderMesh)
-
-QT_END_HEADER
-
-#endif // CYLINDER_H
diff --git a/src/imports/shapes/cylindermesh_p.h b/src/imports/shapes/cylindermesh_p.h
deleted file mode 100644
index a5ad562f..00000000
--- a/src/imports/shapes/cylindermesh_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CYLINDERMESH_P_H
-#define CYLINDERMESH_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.
-//
-
-#include <QtCore/QMap>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsScale3D;
-class QGLSceneNode;
-
-class CylinderMeshPrivate
-{
-public:
- CylinderMeshPrivate();
- ~CylinderMeshPrivate();
-
- QMap<int, QGLSceneNode *> lodGeometry;
- QGLSceneNode *topNode;
- QGLSceneNode *currentCylinder;
- QGraphicsScale3D *scale;
- qreal radius;
- qreal length;
- int lod;
- bool sceneSet;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // CYLINDERMESH_P_H
diff --git a/src/imports/shapes/library.xml b/src/imports/shapes/library.xml
deleted file mode 100644
index d03e3f64..00000000
--- a/src/imports/shapes/library.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module>
- <type name="Capsule" defaultProperty="data" extends="QDeclarativeItem3D">
- <exports>
- <export module="Qt3D.Shapes" version="1.0" type="Capsule" />
- </exports>
- <property name="radius" type="qreal" />
- <property name="length" type="qreal" />
- <property name="levelOfDetail" type="int" />
- <signal name="radiusChanged" />
- <signal name="lengthChanged" />
- <signal name="levelOfDetailChanged" />
- </type>
- <type name="Cylinder" defaultProperty="data" extends="QDeclarativeItem3D">
- <exports>
- <export module="Qt3D.Shapes" version="1.0" type="Cylinder" />
- </exports>
- <property name="radius" type="qreal" />
- <property name="length" type="qreal" />
- <property name="levelOfDetail" type="int" />
- <signal name="radiusChanged" />
- <signal name="lengthChanged" />
- <signal name="levelOfDetailChanged" />
- </type>
- <type name="Line" defaultProperty="data" extends="QDeclarativeItem3D">
- <exports>
- <export module="Qt3D.Shapes" version="1.0" type="Line" />
- </exports>
- <property name="width" type="qreal" />
- <property name="vertices" type="QVariant" />
- <signal name="verticesChanged" />
- <signal name="widthChanged" />
- </type>
- <type name="Point" defaultProperty="data" extends="QDeclarativeItem3D">
- <exports>
- <export module="Qt3D.Shapes" version="1.0" type="Point" />
- </exports>
- <property name="pointSize" type="qreal" />
- <property name="vertices" type="QVariant" />
- <signal name="verticesChanged" />
- <signal name="pointSizeChanged" />
- </type>
- <type name="Sphere" defaultProperty="data" extends="QDeclarativeItem3D">
- <exports>
- <export module="Qt3D.Shapes" version="1.0" type="Sphere" />
- </exports>
- <property name="radius" type="qreal" />
- <property name="levelOfDetail" type="int" />
- <property name="axis" type="Qt.Axis" />
- <signal name="radiusChanged" />
- <signal name="levelOfDetailChanged" />
- <signal name="axisChanged" />
- </type>
-</module>
diff --git a/src/imports/shapes/line.cpp b/src/imports/shapes/line.cpp
deleted file mode 100644
index f93a2b00..00000000
--- a/src/imports/shapes/line.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "line.h"
-#include "qglbuilder.h"
-
-/*!
- \qmlclass Line Line
- \brief The Line item represents a geometric line drawn in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The Line element in QML provides a means of drawing lines in a 3D
- environment. For example, the following QML code draws a line between
- point (0,0,0), (1,1,1), then to (-1,-1,-1).
-
- \code
-
- Line {
- vertices: [
- 0, 0, 0,
- 0, 0, 1,
- 0, 1, 1
-
- ]
- effect: Effect {
- color: "#aaca00"
- }
- }
- \endcode
-
- The Line element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- \sa Item3D
-*/
-/*!
- \internal
-*/
-Line::Line(QObject *parent) :
- QDeclarativeItem3D(parent)
- ,m_width(3.0)
- ,m_geometry(0)
- ,m_changeFlag(false)
-{
- //meh
-}
-
-/*!
- \qmlproperty list<real> Line::vertices
-
- This property defines the positions for all of the vertices in the
- line strip. Each vertex is given by three real values, defining
- the x, y, and z co-ordinates of the vertex.
-*/
-
-QVariant Line::vertices() const
-{
- return m_vertices;
-}
-
-void Line::setVertices(const QVariant &value)
-{
- m_vertices = value;
-
- //Update the actual QVector3DArray containing the line points.
- m_vertexArray.clear();
- QVariantList vertlist = m_vertices.toList();
- for (int index = 0; (index + 2) < vertlist.size(); index += 3) {
- m_vertexArray.append(qreal(vertlist.at(index).toDouble()), qreal(vertlist.at(index + 1).toDouble()), qreal(vertlist.at(index + 2).toDouble()));
- }
- m_changeFlag=true;
- emit verticesChanged();
- update();
-}
-
-
-/*!
- \qmlproperty real Line::width
-
- This property defines the width of the line. The
- default is 1.0
-*/
-void Line::setWidth(qreal width)
-{
- if (m_width != width) {
- m_width = width;
- m_changeFlag=true;
- emit widthChanged();
- update();
- }
-}
-
-/*!
- \internal
-*/
-void Line::drawItem(QGLPainter *painter)
-{
- if (m_changeFlag || !m_geometry) {
- if (m_geometry) delete m_geometry;
-
- QGeometryData lineCollection;
- lineCollection.appendVertexArray(m_vertexArray);
-
- QGLBuilder builder;
- builder.newSection();
- builder.addTriangles(lineCollection);
- builder.currentNode()->setDrawingMode(QGL::LineStrip);
- builder.currentNode()->setDrawingWidth(m_width);
- m_geometry = builder.finalizedSceneNode();
-
- m_changeFlag = false;
- }
-
- // Draw the geometry.
- m_geometry->draw(painter);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/imports/shapes/line.h b/src/imports/shapes/line.h
deleted file mode 100644
index 4f788dd9..00000000
--- a/src/imports/shapes/line.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 LINE_H
-#define LINE_H
-
-#include "qdeclarativeitem3d.h"
-#include "qglscenenode.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Line : public QDeclarativeItem3D
-{
- Q_OBJECT
- Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged)
- Q_PROPERTY(QVariant vertices READ vertices WRITE setVertices NOTIFY verticesChanged)
-
-public:
- explicit Line(QObject *parent = 0);
- ~Line() {}
-
- QVariant vertices() const;
- void setVertices(const QVariant &value);
-
- qreal width() const {return m_width;}
- void setWidth(qreal width);
-
-Q_SIGNALS:
- void verticesChanged();
- void widthChanged();
-
-protected:
- void drawItem(QGLPainter *painter);
-
-private:
- qreal m_width;
- QVariant m_vertices;
- QVector3DArray m_vertexArray;
- QGLSceneNode * m_geometry;
- bool m_changeFlag;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Line)
-
-QT_END_HEADER
-
-#endif // LINE_H
diff --git a/src/imports/shapes/plugins.qmltypes b/src/imports/shapes/plugins.qmltypes
deleted file mode 100755
index 435d7d3f..00000000
--- a/src/imports/shapes/plugins.qmltypes
+++ /dev/null
@@ -1,159 +0,0 @@
-import QtQuick.tooling 1.0
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-
-Module {
- Component {
- name: "Capsule"
- defaultProperty: "data"
- prototype: "QDeclarativeItem3D"
- exports: [
- "Capsule 1.0"
- ]
- Property { name: "radius"; type: "qreal" }
- Property { name: "length"; type: "qreal" }
- Property { name: "levelOfDetail"; type: "int" }
- Signal { name: "radiusChanged" }
- Signal { name: "lengthChanged" }
- Signal { name: "levelOfDetailChanged" }
- }
- Component {
- name: "Cylinder"
- defaultProperty: "data"
- prototype: "QDeclarativeItem3D"
- exports: [
- "Cylinder 1.0"
- ]
- Property { name: "radius"; type: "qreal" }
- Property { name: "length"; type: "qreal" }
- Property { name: "levelOfDetail"; type: "int" }
- Signal { name: "radiusChanged" }
- Signal { name: "lengthChanged" }
- Signal { name: "levelOfDetailChanged" }
- }
- Component {
- name: "Line"
- defaultProperty: "data"
- prototype: "QDeclarativeItem3D"
- exports: [
- "Line 1.0"
- ]
- Property { name: "width"; type: "qreal" }
- Property { name: "vertices"; type: "QVariant" }
- Signal { name: "verticesChanged" }
- Signal { name: "widthChanged" }
- }
- Component {
- name: "Point"
- defaultProperty: "data"
- prototype: "QDeclarativeItem3D"
- exports: [
- "Point 1.0"
- ]
- Property { name: "pointSize"; type: "qreal" }
- Property { name: "vertices"; type: "QVariant" }
- Signal { name: "verticesChanged" }
- Signal { name: "pointSizeChanged" }
- }
- Component {
- name: "QDeclarativeItem3D"
- defaultProperty: "data"
- prototype: "QDeclarativeItem"
- Enum {
- name: "CullFace"
- values: {
- "CullDisabled": 0,
- "CullFrontFaces": 1028,
- "CullBackFaces": 1029,
- "CullAllFaces": 1032,
- "CullClockwise": 65536
- }
- }
- Enum {
- name: "CullFaces"
- values: {
- "CullDisabled": 0,
- "CullFrontFaces": 1028,
- "CullBackFaces": 1029,
- "CullAllFaces": 1032,
- "CullClockwise": 65536
- }
- }
- Enum {
- name: "SortMode"
- values: {
- "DefaultSorting": 0,
- "BackToFront": 1
- }
- }
- Property { name: "position"; type: "QVector3D" }
- Property { name: "x"; type: "qreal" }
- Property { name: "y"; type: "qreal" }
- Property { name: "z"; type: "qreal" }
- Property { name: "scale"; type: "qreal" }
- Property { name: "transform"; type: "QGraphicsTransform3D"; isList: true; isReadonly: true }
- Property { name: "pretransform"; type: "QGraphicsTransform3D"; isList: true; isReadonly: true }
- Property { name: "mesh"; type: "QDeclarativeMesh"; isPointer: true }
- Property { name: "effect"; type: "QDeclarativeEffect"; isPointer: true }
- Property { name: "light"; type: "QGLLightParameters"; isPointer: true }
- Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "children"; type: "QDeclarativeItem3D"; isList: true; isReadonly: true }
- Property { name: "cullFaces"; type: "CullFaces" }
- Property { name: "sortChildren"; type: "SortMode" }
- Property { name: "meshNode"; type: "string" }
- Property { name: "inheritEvents"; type: "bool" }
- Property { name: "enabled"; type: "bool" }
- Property { name: "parent"; type: "QDeclarativeItem3D"; isPointer: true }
- Signal { name: "positionChanged" }
- Signal { name: "scaleChanged" }
- Signal { name: "rotationChanged" }
- Signal { name: "meshChanged" }
- Signal { name: "meshNodeChanged" }
- Signal { name: "effectChanged" }
- Signal { name: "lightChanged" }
- Signal {
- name: "stateChanged"
- Parameter { type: "string" }
- }
- Signal { name: "clicked" }
- Signal { name: "doubleClicked" }
- Signal { name: "pressed" }
- Signal { name: "released" }
- Signal { name: "hoverEnter" }
- Signal { name: "hoverLeave" }
- Signal { name: "inheritEventsChanged" }
- Signal { name: "enabledChanged" }
- Signal { name: "childrenChanged" }
- Signal { name: "parentChanged" }
- Signal { name: "sortChildrenChanged" }
- Method { name: "update" }
- Method {
- name: "localToWorld"
- type: "QVector3D"
- Parameter { name: "point"; type: "QVector3D" }
- }
- Method { name: "localToWorld"; type: "QVector3D" }
- Method {
- name: "worldToLocal"
- type: "QVector3D"
- Parameter { name: "point"; type: "QVector3D" }
- }
- Method { name: "worldToLocal"; type: "QVector3D" }
- }
- Component {
- name: "Sphere"
- defaultProperty: "data"
- prototype: "QDeclarativeItem3D"
- exports: [
- "Sphere 1.0"
- ]
- Property { name: "radius"; type: "qreal" }
- Property { name: "levelOfDetail"; type: "int" }
- Property { name: "axis"; type: "Qt::Axis" }
- Signal { name: "radiusChanged" }
- Signal { name: "levelOfDetailChanged" }
- Signal { name: "axisChanged" }
- }
-}
diff --git a/src/imports/shapes/point.cpp b/src/imports/shapes/point.cpp
deleted file mode 100644
index 8f270975..00000000
--- a/src/imports/shapes/point.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "point.h"
-#include "qglbuilder.h"
-
-/*!
- \qmlclass Point Point
- \brief The Point item represents a geometric point drawn in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The Point element in QML provides a means of drawing points in a 3D
- environment. For example, the following QML code draws points (0,0,0),
- (1,1,1), and (-1,-1,-1).
-
- \code
- Point {
- vertices: [
- 0, 0, 0,
- 1, 1, 1,
- -1, -1, -1
- ]
- effect: Effect {
- useLighting: false
- color: "#aaca00"
- }
- }
- \endcode
-
- The Point element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The Point element is intended only for drawing simple points, and does not
- support point sprites or effect attributes other than color.
-
- \sa Item3D
-*/
-/*!
- \internal
-*/
-Point::Point(QObject *parent) :
- QDeclarativeItem3D(parent)
- , m_pointSize(1.0f)
- , m_changeFlag(false)
-{
- //meh
-}
-
-
-/*!
- \qmlproperty list<real> Point::vertices
-
- This property defines the positions for all of the points to be drawn
- Each vertex is given by three real values, defining
- the x, y, and z co-ordinates of the vertex.
-*/
-
-QVariant Point::vertices() const
-{
- return m_vertices;
-}
-
-void Point::setVertices(const QVariant &value)
-{
- m_vertices = value;
-
- //Update the actual QVector3DArray containing the points.
- m_vertexArray.clear();
- QVariantList vertlist = m_vertices.toList();
- for (int index = 0; (index + 2) < vertlist.size(); index += 3) {
- m_vertexArray.append(qreal(vertlist.at(index).toDouble()), qreal(vertlist.at(index + 1).toDouble()), qreal(vertlist.at(index + 2).toDouble()));
- }
- m_changeFlag=true;
- emit verticesChanged();
- update();
-}
-
-
-/*!
- \qmlproperty qreal Point::pointSize
-
- This property defines the size of the point. The
- default is 1.0
-*/
-void Point::setPointSize(qreal pointSize)
-{
- if (m_pointSize != pointSize) {
- m_pointSize = pointSize;
- m_changeFlag=true;
- emit pointSizeChanged();
- update();
- }
-}
-
-/*!
- \internal
-*/
-void Point::drawItem(QGLPainter *painter)
-{
- if (m_changeFlag || !m_geometry) {
- if (m_geometry) delete m_geometry;
-
- QGLBuilder builder;
-
- QGeometryData pointCollection;
- builder.newSection();
-
- pointCollection.appendVertexArray(m_vertexArray);
-
- builder.addTriangles(pointCollection);
- builder.currentNode()->setDrawingMode(QGL::Points);
- builder.currentNode()->setDrawingWidth(m_pointSize);
- m_geometry = builder.finalizedSceneNode();
-
- m_changeFlag = false;
- }
-
- // Draw the geometry.
- m_geometry->draw(painter);
-}
-
-QT_END_NAMESPACE
-
-
diff --git a/src/imports/shapes/point.h b/src/imports/shapes/point.h
deleted file mode 100644
index 591f4d8a..00000000
--- a/src/imports/shapes/point.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 POINT_H
-#define POINT_H
-
-#include "qdeclarativeitem3d.h"
-#include "qglscenenode.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Point : public QDeclarativeItem3D
-{
- Q_OBJECT
- Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged)
- Q_PROPERTY(QVariant vertices READ vertices WRITE setVertices NOTIFY verticesChanged)
-
-public:
- explicit Point(QObject *parent = 0);
- ~Point() {}
-
- QVariant vertices() const;
- void setVertices(const QVariant &value);
-
- qreal pointSize() const {return m_pointSize;}
- void setPointSize(qreal pointSize);
-
-Q_SIGNALS:
- void verticesChanged();
- void pointSizeChanged();
-
-protected:
- void drawItem(QGLPainter *painter);
-
-private:
- qreal m_pointSize;
- QVariant m_vertices;
- QVector3DArray m_vertexArray;
- QGLSceneNode * m_geometry;
- bool m_changeFlag;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Point)
-
-QT_END_HEADER
-
-#endif // POINT_H
diff --git a/src/imports/shapes/qmldir b/src/imports/shapes/qmldir
deleted file mode 100644
index dd4f575d..00000000
--- a/src/imports/shapes/qmldir
+++ /dev/null
@@ -1,7 +0,0 @@
-plugin qshapesqmlplugin
-Cube 1.0 Cube.qml
-Teapot 1.0 Teapot.qml
-Quad 1.0 Quad.qml
-Sphere 1.0 Sphere.qml
-Capsule 1.0 Capsule.qml
-Cylinder 1.0 Cylinder.qml
diff --git a/src/imports/shapes/quad.obj b/src/imports/shapes/quad.obj
deleted file mode 100644
index a28dee25..00000000
--- a/src/imports/shapes/quad.obj
+++ /dev/null
@@ -1,12 +0,0 @@
-o Plane
-v 0.500000 0.000000 -0.500000
-v 0.500000 0.000000 0.500000
-v -0.500000 0.000000 0.500000
-v -0.500000 0.000000 -0.500000
-vt 1.000000 0.000000
-vt 1.000000 1.000000
-vt 0.000000 1.000000
-vt 0.000000 0.000000
-usemtl (null)
-s off
-f 1/2 4/3 3/4 2/1
diff --git a/src/imports/shapes/quad.qdoc b/src/imports/shapes/quad.qdoc
deleted file mode 100644
index b13a40a6..00000000
--- a/src/imports/shapes/quad.qdoc
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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$
-**
-****************************************************************************/
-
-/*!
- \qmlclass Quad Quad
- \brief The Quad item represents a simple quad in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The Quad element in QML provides a simple way to create a regular
- quad object, usually for testing material effects. For example,
- the following QML code displays a quad of size 1.5, centered
- on the origin and covered in the Qt logo texture:
-
- \code
- Quad {
- scale: 1.5
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- }
- }
- \endcode
-
- The Quad element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The quad can be moved from the origin by specifying the
- Item3D::position property:
-
- \code
- Quad {
- scale: 1.5
- position: Qt.vector3d(1, 0, 5)
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- }
- }
- \endcode
-
- \sa Item3D
-*/
diff --git a/src/imports/shapes/shapes.cpp b/src/imports/shapes/shapes.cpp
deleted file mode 100644
index 7c1958c6..00000000
--- a/src/imports/shapes/shapes.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 <QtDeclarative/qdeclarativeextensionplugin.h>
-
-#include "spheremesh.h"
-#include "cylindermesh.h"
-#include "capsulemesh.h"
-#include "line.h"
-#include "point.h"
-
-QT_BEGIN_NAMESPACE
-
-class QShapesQmlModule : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- virtual void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt3D.Shapes"));
- qmlRegisterType<SphereMesh>(uri,1,0,"SphereMesh");
- qmlRegisterType<CylinderMesh>(uri,1,0,"CylinderMesh");
- qmlRegisterType<CapsuleMesh>(uri,1,0,"CapsuleMesh");
- qmlRegisterType<Line>(uri,1,0,"Line");
- qmlRegisterType<Point>(uri,1,0,"Point");
-
- }
-};
-
-QT_END_NAMESPACE
-
-#include "shapes.moc"
-
-Q_EXPORT_PLUGIN2(qshapesqmlplugin, QT_PREPEND_NAMESPACE(QShapesQmlModule));
diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro
deleted file mode 100644
index 002446d4..00000000
--- a/src/imports/shapes/shapes.pro
+++ /dev/null
@@ -1,101 +0,0 @@
-TEMPLATE = lib
-TARGET = qshapesqmlplugin
-CONFIG += qt plugin
-
-CONFIG += qt3dquick_deploy_pkg
-include(../../../pkg.pri)
-
-# See the README in the root dir re this code
-package {
- target.path += $$QT3D_INSTALL_IMPORTS/Qt3D/Shapes
- INSTALLS += target
- QT += declarative
-} else {
- CONFIG += qt3dquick qt3d
- DESTDIR = $$QT3D_INSTALL_IMPORTS/Qt3D/Shapes
-}
-
-win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- }
-}
-
-symbian {
- CONFIG += epocallowdlldata
- MMP_RULES += EXPORTUNFROZEN
- LIBS += -lQt3D$${QT_LIBINFIX} -lQt3DQuick$${QT_LIBINFIX}
- TARGET.EPOCALLOWDLLDATA = 1
- TARGET.CAPABILITY = All -Tcb
- TARGET.UID3 = 0x20031E9C
-}
-
-SOURCES += \
- shapes.cpp \
- line.cpp \
- point.cpp \
- spheremesh.cpp \
- capsulemesh.cpp \
- cylindermesh.cpp
-HEADERS += \
- line.h \
- point.h \
- spheremesh.h \
- spheremesh_p.h \
- capsulemesh.h \
- cylindermesh.h \
- capsulemesh_p.h \
- cylindermesh_p.h
-
-QML_FILES = \
- Cube.qml \
- Sphere.qml \
- Quad.qml \
- Teapot.qml \
- Capsule.qml \
- Cylinder.qml
-
-QML_INFRA_FILES += \
- $$QML_FILES \
- qmldir \
- library.xml \
- plugins.qmltypes \
- cube.obj \
- quad.obj \
- teapot.bez
-# see the file README.library_xml for more on library.xml
-
-package {
- copyqmlinfra_install.files = $$QML_INFRA_FILES
- copyqmlinfra_install.path = $$QT3D_INSTALL_IMPORTS/Qt3D/Shapes
- INSTALLS += copyqmlinfra_install
-} else {
- copyqmlinfra.input = QML_INFRA_FILES
- copyqmlinfra.output = $$[QT_INSTALL_IMPORTS]/Qt3D/Shapes/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- copyqmlinfra.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- copyqmlinfra.CONFIG += no_link_no_clean
- copyqmlinfra.variable_out = PRE_TARGETDEPS
- QMAKE_EXTRA_COMPILERS += copyqmlinfra
-}
-
-OTHER_FILES += \
- README.plugins_types \
- README.library_xml
-
-OTHER_FILES += $$QML_FILES
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/imports/shapes/spheremesh.cpp b/src/imports/shapes/spheremesh.cpp
deleted file mode 100644
index 72bf1dee..00000000
--- a/src/imports/shapes/spheremesh.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "spheremesh.h"
-#include "qglbuilder.h"
-#include "qglsphere.h"
-#include "qgraphicsrotation3d.h"
-#include "qgraphicsscale3d.h"
-#include "qglabstractscene.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass SphereMesh SphereMesh
- \brief The SphereMesh item represents a simple UV-sphere in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The SphereMesh element in QML provides a simple way to create a sphere
- object, usually for testing material effects. For example,
- the following QML code displays a green sphere mesh of radius 1.5,
- centered on the origin:
-
- \code
- Item3D {
- mesh: SphereMesh { radius: 1.5 }
- effect: Effect { color: "#aaca00" }
- }
- \endcode
-
- As shown, the mesh is only displayed when it is set as the target of
- a mesh property on an Item3D.
-
- The SphereMesh element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- By default, the sphere is aligned to lie along the Z axis.
- The \l axis property can change this to either the X or the Y
- axis, as shown in the following example:
-
- \code
- SphereMesh {
- radius: 1.5
- axis: Qt.YAxis
- }
- \endcode
-
- To display the sphere mesh you can create your own Item3D as shown
- above, or use the convenience Sphere QML component:
-
- \code
- Sphere {
- radius: 1.5
- levelOfDetail: 6
- axis: Qt.YAxis
- effect: Effect { texture: "moon-texture.jpg" }
- }
- \endcode
-
- \image moon-screenshot.png
-
- \section1 Performance Hints for Larger Scenes
-
- The convenience Sphere QML component will create a new mesh each
- time it is instantiated.
-
- If you have a scene with a number of similar spheres use your own
- Item3D elements to all refer to the same mesh - this will save on
- graphics memory and improve the performance of your application since
- there is no need to recreate many copies of the same geometry. This
- is true even if you want to apply different materials, effects or
- transformations to each sphere.
-
- To do this, first declare the SphereMesh object, outside of any Item3D
- so that it won't get drawn, and give it an id so you can refer to it.
-
- \snippet quick3d/solarsystem_qml/qml/solarsystem_qml.qml 0
-
- Then set the various effects and so on you need for each instance of
- the sphere. If you need different sized spheres you can use a scale,
- and of course you can specify materials and effects.
-
- \snippet quick3d/solarsystem_qml/qml/solarsystem_qml.qml 1
-
- In this case since only one copy of the triangle data for the mesh is
- sent to the GPU performance will generally be better.
-
- \section1 Performance Hints for Animation
-
- Some support for animation of the SphereMesh properties is provided
- by utilizing a QGraphicsScale3D to implement the radius property,
- and by caching levels of detail.
-
- So within limits animation of these items should provide reasonable
- results. Be aware that on constrained devices animation of the
- level of detail for many spheres could cause problems with memory
- usage due to the caching.
-
- The other shapes primitives are implemented differently with respect
- to radius, length and so on, so read the performance notes there, as
- they will differ from the sphere case.
-
- \sa Item3D
-*/
-
-SphereMeshPrivate::SphereMeshPrivate()
- : topNode(new QGLSceneNode)
- , currentSphere(0)
- , rot(0)
- , scale(0)
- , radius(1.0f)
- , lod(5)
- , axis(Qt::ZAxis)
- , sceneSet(false)
-{
- topNode->setObjectName("SphereMesh");
-}
-
-SphereMeshPrivate::~SphereMeshPrivate()
-{
- topNode->removeNode(currentSphere);
- delete topNode;
- QList<QGLSceneNode*> lods = lodGeometry.values();
- qDeleteAll(lods);
-}
-
-class SphereScene : public QGLAbstractScene
-{
-public:
- explicit SphereScene(QGLSceneNode *s) : m_s(s) {}
- ~SphereScene() {}
- QList<QObject *> objects() const
- {
- QList<QObject *> s;
- s.append(m_s);
- return s;
- }
- QGLSceneNode *mainNode() const
- {
- return m_s;
- }
-private:
- QGLSceneNode *m_s;
-};
-
-/*!
- \internal
-*/
-SphereMesh::SphereMesh(QObject *parent)
- : QDeclarativeMesh(parent)
- , d_ptr(new SphereMeshPrivate)
-{
-}
-
-/*!
- \qmlproperty real SphereMesh::radius
-
- This property defines the radius of the sphere. The default
- value is 1.
-*/
-qreal SphereMesh::radius() const
-{
- Q_D(const SphereMesh);
- return d->radius;
-}
-
-void SphereMesh::setRadius(qreal radius)
-{
- Q_D(SphereMesh);
- if (qFuzzyCompare(radius, 1))
- radius = 1.0f;
- if (d->radius != radius)
- {
- d->radius = radius;
- createGeometry();
- emit radiusChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty int SphereMesh::levelOfDetail
-
- This property defines the level of detail, between 1 and 10,
- which controls the number of triangles that are generated to
- render the surface of the sphere. Values outside the range
- 1 to 10 will be clamped to the range when the sphere is drawn.
-
- The default value is 5. An increase in 1 in level of detail
- doubles the number of triangles. The following picture shows
- the effect of level of detail values between 1 and 10:
-
- \image sphere-detail.png
-
- \table
- \header \o Level of Detail \o Number of Triangles
- \row \o 1 \o 64
- \row \o 2 \o 128
- \row \o 3 \o 256
- \row \o 4 \o 512
- \row \o 5 \o 1024
- \row \o 6 \o 2048
- \row \o 7 \o 4096
- \row \o 8 \o 8192
- \row \o 9 \o 16384
- \row \o 10 \o 32768
- \endtable
-*/
-int SphereMesh::levelOfDetail() const
-{
- Q_D(const SphereMesh);
- return d->lod;
-}
-
-void SphereMesh::setLevelOfDetail(int lod)
-{
- Q_D(SphereMesh);
- lod = qBound(1, lod, 10);
- if (d->lod != lod)
- {
- d->lod = lod;
- createGeometry();
- emit levelOfDetailChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration SphereMesh::axis
-
- This property defines the axis that the sphere lies along.
- The default is Qt.ZAxis. The other supported values are
- Qt.XAxis and Qt.YAxis. This provides a simple method to
- orient the sphere in the desired direction.
-*/
-Qt::Axis SphereMesh::axis() const
-{
- Q_D(const SphereMesh);
- return d->axis;
-}
-
-void SphereMesh::setAxis(Qt::Axis axis)
-{
- Q_D(SphereMesh);
- if (d->axis != axis)
- {
- d->axis = axis;
- createGeometry();
- emit axisChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \internal
-*/
-void SphereMesh::draw(QGLPainter *painter, int branchId)
-{
- Q_D(SphereMesh);
- if (!d->currentSphere)
- createGeometry();
- QDeclarativeMesh::draw(painter, branchId);
-}
-
-/*!
- \internal
-*/
-void SphereMesh::createGeometry()
-{
- Q_D(SphereMesh);
-
- // We cache a maximum of 10 levels of detail for lod animations.
- // Create a new geometry node for this level of detail if necessary.
- QGLSceneNode *geometry = d->lodGeometry.value(d->lod, 0);
- if (!geometry) {
- QGLBuilder builder;
- builder.newSection(QGL::Faceted);
- builder << QGLSphere(2.0f, d->lod);
- geometry = builder.finalizedSceneNode();
- geometry->setParent(this);
- d->lodGeometry.insert(d->lod, geometry);
- }
- Q_ASSERT_X(geometry != 0, Q_FUNC_INFO, "Could not create/find geometry!");
- if (d->currentSphere != geometry)
- {
- if (d->currentSphere)
- d->topNode->removeNode(d->currentSphere);
- d->topNode->addNode(geometry);
- d->currentSphere = geometry;
- }
-
- // Set the radius as a scale on the modelview transformation.
- // This way, we don't have to regenerate the geometry every
- // frame if the radius is being animated.
- if (d->radius != 1.0f)
- {
- if (!d->scale)
- {
- d->scale = new QGraphicsScale3D(d->topNode);
- d->topNode->addTransform(d->scale);
- }
- if (d->scale->scale().x() != d->radius)
- {
- d->scale->setScale(QVector3D(d->radius, d->radius, d->radius));
- }
- }
- else
- {
- // If there is already a scale set it to be the identity scale.
- // This case is optimised for in QGraphicsScale. Removing it from
- // the transform list is too expensive, especially if the size is
- // being animated, and the next frame will recreate it.
- if (d->scale)
- d->scale->setScale(QVector3D(1, 1, 1));
- }
-
- // Also rotate the geometry into the correct axis orientation.
- const QVector3D Y_AXIS = QVector3D(0, 1, 0); // for Qt::XAxis we rotate around Y
- const QVector3D X_AXIS = QVector3D(1, 0, 0); // for Qt::YAxis we rotate around X
- if (d->axis != Qt::ZAxis && !d->rot)
- {
- d->rot = new QGraphicsRotation3D(d->topNode);
- d->topNode->addTransform(d->rot);
- }
- if (d->axis == Qt::XAxis && d->rot->axis().y() != Y_AXIS.y())
- {
- d->rot->setAxis(Y_AXIS);
- d->rot->setAngle(90.0f);
- }
- else if (d->axis == Qt::YAxis && d->rot->axis().x() != X_AXIS.x())
- {
- d->rot->setAxis(X_AXIS);
- d->rot->setAngle(-90.0f);
- }
- else if (d->axis == Qt::ZAxis && d->rot && d->rot->angle() != 0.0f)
- {
- d->rot->setAngle(0.0f);
- d->rot->setAxis(QVector3D(0, 0, 0));
- }
-
- if (!d->sceneSet)
- {
- setScene(new SphereScene(d->topNode));
- d->sceneSet = true;
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/imports/shapes/spheremesh.h b/src/imports/shapes/spheremesh.h
deleted file mode 100644
index b4e2b4f0..00000000
--- a/src/imports/shapes/spheremesh.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SPHEREMESH_H
-#define SPHEREMESH_H
-
-#include "qglscenenode.h"
-#include "qdeclarativemesh.h"
-#include "spheremesh_p.h"
-
-#include <QtCore/qmap.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class SpherePrivate;
-
-class SphereMesh : public QDeclarativeMesh
-{
- Q_OBJECT
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
- Q_PROPERTY(int levelOfDetail READ levelOfDetail WRITE setLevelOfDetail NOTIFY levelOfDetailChanged)
- Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
-public:
- SphereMesh(QObject *parent = 0);
- ~SphereMesh() {}
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- int levelOfDetail() const;
- void setLevelOfDetail(int lod);
-
- Qt::Axis axis() const;
- void setAxis(Qt::Axis axis);
-
- void draw(QGLPainter *painter, int branchId);
-
-Q_SIGNALS:
- void radiusChanged();
- void levelOfDetailChanged();
- void axisChanged();
-
-private:
- void createGeometry();
-
- Q_DISABLE_COPY(SphereMesh)
- Q_DECLARE_PRIVATE(SphereMesh)
-
- QScopedPointer<SphereMeshPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(SphereMesh)
-
-QT_END_HEADER
-
-#endif // SPHEREMESH_H
diff --git a/src/imports/shapes/spheremesh_p.h b/src/imports/shapes/spheremesh_p.h
deleted file mode 100644
index 3d407421..00000000
--- a/src/imports/shapes/spheremesh_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SPHEREMESH_P_H
-#define SPHEREMESH_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.
-//
-
-#include <QtCore/QMap>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsRotation3D;
-class QGraphicsScale3D;
-class QGLSceneNode;
-
-class SphereMeshPrivate
-{
-public:
- SphereMeshPrivate();
- ~SphereMeshPrivate();
-
- QMap<int, QGLSceneNode *> lodGeometry;
- QGLSceneNode *topNode;
- QGLSceneNode *currentSphere;
- QGraphicsRotation3D *rot;
- QGraphicsScale3D *scale;
- qreal radius;
- int lod;
- Qt::Axis axis;
- bool sceneSet;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // SPHEREMESH_P_H
diff --git a/src/imports/shapes/teapot.bez b/src/imports/shapes/teapot.bez
deleted file mode 100644
index 02b2ac44..00000000
--- a/src/imports/shapes/teapot.bez
+++ /dev/null
@@ -1,340 +0,0 @@
-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/src/imports/shapes/teapot.h b/src/imports/shapes/teapot.h
deleted file mode 100644
index 90f7a95b..00000000
--- a/src/imports/shapes/teapot.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 CUBE_H
-#define CUBE_H
-
-// This is a dummy header for defining the interface of "Teapot.qml" to qdoc.
-
-#include "qdeclarativeitem3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Teapot : public QDeclarativeItem3D
-{
- Q_OBJECT
-public:
- Teapot(QObject *parent = 0) : QDeclarativeItem3D(parent) {}
- ~Teapot() {}
-};
-
-QML_DECLARE_TYPE(Cube)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/imports/shapes/teapot.qdoc b/src/imports/shapes/teapot.qdoc
deleted file mode 100644
index 8c6470f0..00000000
--- a/src/imports/shapes/teapot.qdoc
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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$
-**
-****************************************************************************/
-
-/*!
- \qmlclass Teapot Teapot
- \brief The Teapot item represents a stock teapot object.
- \since 4.8
- \ingroup qt3d::qml3d::shapes
- \inherits Item3D
-
- The Teapot element in QML provides a simple way to create a teapot
- object, usually for testing material effects and complex
- geometry. For example, the following QML code displays a teapot
- of size 1.5, centered on the origin and covered in the Qt logo
- texture:
-
- \code
- Teapot {
- scale: 1.5
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- decal: true
- }
- }
- \endcode
-
- \image teapot-qt-screenshot.png
-
- The Teapot element is part of the \c{Qt3D.Shapes} namespace,
- so the following must appear at the top of any QML file that
- references it:
-
- \code
- import Qt3D.Shapes 1.0
- \endcode
-
- The teapot can be moved from the origin by specifying the
- Item3D::position property:
-
- \code
- Teapot {
- scale: 1.5
- position: Qt.vector3d(1, 0, 5)
- effect: Effect {
- color: "#aaca00"
- texture: "qtlogo.png"
- decal: true
- }
- }
- \endcode
-
- \sa Item3D
-*/
diff --git a/src/imports/threed/DefaultNavigator.qml b/src/imports/threed/DefaultNavigator.qml
deleted file mode 100644
index 70b0ac6b..00000000
--- a/src/imports/threed/DefaultNavigator.qml
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 Qt 4.7
-import Qt3D 1.0
-
-// This is an example of how to implement a custom navigation strategy
-// to replace the default strategy implemented by "Viewport".
-
-MouseArea {
- // Set this property to the "Viewport" item to be controlled
- // by this navigator. By default we assume that it is our parent.
- property variant viewport: parent
-
- // The navigator fills the entire viewport.
- anchors.fill: viewport
-
- // Private variables.
- QtObject {
- id: d_ptr
- property bool panning: false
- property int startX: 0
- property int startY: 0
- property variant startEye
- property variant startCenter
- property variant startUpVector
- property variant pressedObject: null
- property variant enteredObject: null
- property bool sawDoubleClick: false
- }
-
- // Handle mouse press events.
- onPressed: {
- // Determine which object was pressed in the viewport.
- var objectUnderMouse;
- if (!d_ptr.panning && viewport.picking)
- objectUnderMouse = viewport.objectForPoint(mouse.x, mouse.y);
- else
- objectUnderMouse = null;
- if (d_ptr.pressedObject) {
- // We already have a pressed object, so nothing to do.
- mouse.accepted = true;
- } else if (Qt.isQtObject(objectUnderMouse)) {
- // Mouse press on a new object.
- d_ptr.pressedObject = objectUnderMouse;
- d_ptr.enteredObject = null;
- d_ptr.sawDoubleClick = false;
- objectUnderMouse.pressed();
- mouse.accepted = true;
- } else if (viewport.navigation && mouse.button == Qt.LeftButton) {
- // Start panning the view.
- d_ptr.panning = true;
- d_ptr.startX = mouse.x;
- d_ptr.startY = mouse.y;
- d_ptr.startEye = viewport.camera.eye;
- d_ptr.startCenter = viewport.camera.center;
- d_ptr.startUpVector = viewport.camera.upVector;
- mouse.accepted = true;
- }
- }
-
- // Handle mouse release events.
- onReleased: {
- if (d_ptr.panning && mouse.button == Qt.LeftButton) {
- d_ptr.panning = false;
- mouse.accepted = true;
- }
- if (d_ptr.pressedObject && mouse.button == Qt.LeftButton) {
- // Deliver the release event to the pressed object.
- var objectUnderMouse = viewport.objectForPoint(mouse.x, mouse.y);
- if (objectUnderMouse == d_ptr.pressedObject && !d_ptr.sawDoubleClick) {
- d_ptr.pressedObject.released();
- d_ptr.pressedObject.clicked();
- } else {
- d_ptr.pressedObject.released();
- }
- if (hoverEnabled) {
- if (Qt.isQtObject(objectUnderMouse))
- d_ptr.enteredObject = objectUnderMouse;
- else
- d_ptr.enteredObject = null;
- if (d_ptr.enteredObject != d_ptr.pressedObject) {
- d_ptr.pressedObject.hoverLeave();
- if (d_ptr.enteredObject)
- d_ptr.enteredObject.hoverEnter();
- }
- }
- d_ptr.pressedObject = null;
- mouse.accepted = true;
- }
- }
-
- // Handle mouse double click events.
- onDoubleClicked: {
- if (d_ptr.pressedObject) {
- var objectUnderMouse = viewport.objectForPoint(mouse.x, mouse.y);
- if (objectUnderMouse == d_ptr.pressedObject) {
- d_ptr.pressedObject.doubleClicked();
- d_ptr.sawDoubleClick = true;
- mouse.accepted = true;
- }
- }
- }
-
- // Handle mouse move events.
- onPositionChanged: {
- if (d_ptr.panning) {
- var deltaX = mouse.x - d_ptr.startX;
- var deltaY = mouse.y - d_ptr.startY;
- var angleAroundY = deltaX * 90 / width;
- var angleAroundX = deltaY * 90 / height;
-
- viewport.camera.eye = d_ptr.startEye;
- viewport.camera.center = d_ptr.startCenter;
- viewport.camera.upVector = d_ptr.startUpVector;
- viewport.camera.tiltPanRollCenter
- (-angleAroundX, -angleAroundY, 0, "TiltPanRoll");
- } else if (viewport.picking && hoverEnabled) {
- // Handle object enter/leave events when mouse hover is enabled.
- var objectUnderMouse = viewport.objectForPoint(mouse.x, mouse.y);
- if (!d_ptr.pressedObject) {
- if (Qt.isQtObject(objectUnderMouse)) {
- if (d_ptr.enteredObject != objectUnderMouse) {
- if (d_ptr.enteredObject)
- d_ptr.enteredObject.hoverLeave();
- d_ptr.enteredObject = objectUnderMouse;
- d_ptr.enteredObject.hoverEnter();
- }
- } else if (d_ptr.enteredObject) {
- d_ptr.enteredObject.hoverLeave();
- d_ptr.enteredObject = null;
- }
- }
- }
- }
-
- // Handle leave events.
- onExited: {
- if (hoverEnabled && !d_ptr.pressedObject && d_ptr.enteredObject) {
- d_ptr.enteredObject.hoverLeave();
- d_ptr.enteredObject = null;
- }
- }
-}
diff --git a/src/imports/threed/README.library_xml b/src/imports/threed/README.library_xml
deleted file mode 100644
index 0399d4ab..00000000
--- a/src/imports/threed/README.library_xml
+++ /dev/null
@@ -1,15 +0,0 @@
-The library.xml file is required to get syntax highlighting of Qt3D
-plugin items in Qt Creator < version 2.2.
-
-The library.xml file is installed into the imports/Qt3D tree along with
-the plugin and the qmldir file.
-
-When any of the elements - property names, class names or other exports
-- in the Qt3D plugin are changed this file will need to be regenerated.
-
-To generate the library.xml file see the scripts/README file for a
-description of how to use the filter-qmldump.pl script.
-
-This is a less-than-optimal solution but as syntax discovery improves
-in Qt Creator better solutions should become available at which time
-this temporary script and syntax file may be deprecated.
diff --git a/src/imports/threed/README.plugins_types b/src/imports/threed/README.plugins_types
deleted file mode 100755
index e78cd67e..00000000
--- a/src/imports/threed/README.plugins_types
+++ /dev/null
@@ -1,34 +0,0 @@
-The plugins.qmltypes file is required to get syntax highlighting of Qt3D
-plugin items inside Qt Creator 2.2 and later.
-
-To support earlier versions of Qt Creator the library.xml file is used.
-
-The plugins.qmltypes file is installed into the imports/Qt3D tree along
-with the plugin and the qmldir file.
-
-When any of the elements - property names, class names or other exports
-- in the Qt3D plugin are changed this file will need to be regenerated.
-
-To generate the plugins.qmltypes, you first need a qmldump binary generated from
-sources shipped with Qt Creator 2.2 or greater. On Mac these are inside the app
-bundle, other platforms vary. If all else fails get the sources from the Qt
-Creator repo.
-
-To build qmldump you need access to private headers, so therefore it must be
-built against a source build of Qt. On Mac it is helpful to build qmldump with
-"qmake CONFIG-=app_bundle" so that you get a regular command-line binary.
-
-Once you finally have a viable qmldump binary:
-
-./qmldump Qt3D 1.0 $QTDIR/imports > plugins.qmltypes
-
-...where $QTDIR points to the root of the Qt where Qt3D is installed.
-
-If you get a usage error like:
-
-Usage: qmldump [plugin/import/path plugin.uri]
-
-...then the version of qmldump source you used was not for Qt Creator > 2.2 -
-you somehow have the earlier version qmldump sources.
-
-You do not need to use the filter-qmldump.pl script.
diff --git a/src/imports/threed/billboarditem3d.cpp b/src/imports/threed/billboarditem3d.cpp
deleted file mode 100644
index eb94d26f..00000000
--- a/src/imports/threed/billboarditem3d.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "billboarditem3d.h"
-#include "qgraphicsbillboardtransform.h"
-
-/*!
- \qmlclass BillboardItem3D BillboardItem3D
- \brief The BillboardItem3D will always face toward the viewer.
- \since 4.8
- \ingroup qt3d::qml3d
-
- Sometimes it is desirable to have objects which always face toward the
- camera. For example, a quad with text on it may always face the camera
- so as to be readable at all times.
-
- While this can be achieved with a QGraphicsLookAtTransform on a normal
- Item3D, the BillboardItem3D class provides a more efficient "cheat" which
- takes advantage of the underlying 3D mathematics.
-
- To use a BillboardItem3D declare it exactly like a regular Item3D. When
- the item is drawn a QGraphicsBillboardTransform will be applied to the item
- after all other transforms have been performed.
-
- For example:
-
- \code
- Viewport {
- BillboardItem3D {
- mesh: Mesh { source: "model.obj" }
- effect: Effect {
- blending: true
- texture: "texture.png"
- }
- }
- }
- \endcode
-
- For a practical illustration of its use see the forest example.
-*/
-BillboardItem3D::BillboardItem3D(QObject *parent)
- : QDeclarativeItem3D(parent)
-{
- m_preserveUpVector = false;
-}
-
-/*!
- \qmlproperty bool BillboardItem3D::preserveUpVector
-
- This property specifies whether the billboard transform should
- preserve the "up vector" so that objects stay at right angles
- to the ground plane in the scene.
-
- The default value for this property is false, which indicates that
- the object being transformed should always face directly to the camera
- This is also known as a "spherical billboard".
-
- If the value for this property is true, then the object will have
- its up orientation preserved. This is also known as a "cylindrical
- billboard".
-*/
-bool BillboardItem3D::preserveUpVector() const
-{
- return m_preserveUpVector;
-}
-
-void BillboardItem3D::setPreserveUpVector(bool value)
-{
- m_preserveUpVector = value;
- update();
-}
-
-/*!
- \internal
- This replaces the standard draw() as used in Item3D. In this instance all drawing
- carried out using \a painter follows the standard sequence. However, after the
- transforms for the item have been applied, a QGraphicsBillboardTransform is applied
- to the model-view matrix.
-
- After the current item is drawn the model-view matrix from immediately before the
- billboard transform being applied will be restored so child items are not affected by it.
-*/
-void BillboardItem3D::draw(QGLPainter *painter)
-{
- // Bail out if this item and its children have been disabled.
- if (!isEnabled())
- return;
- if (!isInitialized())
- initialize(painter);
-
- //Setup picking
- int prevId = painter->objectPickId();
- painter->setObjectPickId(objectPickId());
-
- //Setup effect (lighting, culling, effects etc)
- const QGLLightParameters *currentLight = 0;
- QMatrix4x4 currentLightTransform;
- drawLightingSetup(painter, currentLight, currentLightTransform);
- bool viewportBlend, effectBlend;
- drawEffectSetup(painter, viewportBlend, effectBlend);
- drawCullSetup();
-
- //Local and Global transforms
- drawTransformSetup(painter);
-
- //After all of the other transforms, apply the billboard transform to
- //ensure forward facing.
- painter->modelViewMatrix().push();
- QGraphicsBillboardTransform bill;
- bill.setPreserveUpVector(m_preserveUpVector);
- bill.applyTo(const_cast<QMatrix4x4 *>(&painter->modelViewMatrix().top()));
-
- //Drawing
- drawItem(painter);
-
- //Pop the billboard transform from the model-view matrix stack so that it
- //is not applied to child items.
- painter->modelViewMatrix().pop();
-
- //Draw children
- drawChildren(painter);
-
- //Cleanup
- drawTransformCleanup(painter);
- drawLightingCleanup(painter, currentLight, currentLightTransform);
- drawEffectCleanup(painter, viewportBlend, effectBlend);
- drawCullCleanup();
-
- //Reset pick id.
- painter->setObjectPickId(prevId);
-}
-
diff --git a/src/imports/threed/billboarditem3d.h b/src/imports/threed/billboarditem3d.h
deleted file mode 100644
index d60b75fa..00000000
--- a/src/imports/threed/billboarditem3d.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 BILLBOARDITEM3D_H
-#define BILLBOARDITEM3D_H
-
-#include "qdeclarativeitem3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class BillboardItem3D : public QDeclarativeItem3D
-{
- Q_OBJECT
- Q_PROPERTY(bool preserveUpVector READ preserveUpVector WRITE setPreserveUpVector)
-public:
- BillboardItem3D(QObject *parent = 0);
-
- bool preserveUpVector() const;
- void setPreserveUpVector(bool value);
-
- void draw(QGLPainter *painter);
-
-private:
- bool m_preserveUpVector;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(BillboardItem3D)
-
-QT_END_HEADER
-
-#endif // BILLBOARDITEM3D_H
diff --git a/src/imports/threed/library.xml b/src/imports/threed/library.xml
deleted file mode 100644
index 8ed2c343..00000000
--- a/src/imports/threed/library.xml
+++ /dev/null
@@ -1,379 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module>
- <type name="QDeclarativeEffect" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="Effect" />
- </exports>
- <property name="color" type="QColor" />
- <property name="useLighting" type="bool" />
- <property name="decal" type="bool" />
- <property name="blending" type="bool" />
- <property name="texture" type="QUrl" />
- <property name="textureImage" type="QImage" />
- <property name="material" type="QGLMaterial" />
- <property name="progress" type="qreal" />
- <signal name="effectChanged" />
- <signal name="progressChanged">
- <param name="progress" type="qreal" />
- </signal>
- </type>
- <type name="QDeclarativeItem3D" defaultProperty="data" extends="QDeclarativeItem">
- <exports>
- <export module="Qt3D" version="1.0" type="Item3D" />
- </exports>
- <enum name="CullFace">
- <enumerator name="CullDisabled" value="0" />
- <enumerator name="CullFrontFaces" value="1028" />
- <enumerator name="CullBackFaces" value="1029" />
- <enumerator name="CullAllFaces" value="1032" />
- <enumerator name="CullClockwise" value="65536" />
- </enum>
- <enum name="CullFaces">
- <enumerator name="CullDisabled" value="0" />
- <enumerator name="CullFrontFaces" value="1028" />
- <enumerator name="CullBackFaces" value="1029" />
- <enumerator name="CullAllFaces" value="1032" />
- <enumerator name="CullClockwise" value="65536" />
- </enum>
- <enum name="SortMode">
- <enumerator name="DefaultSorting" value="0" />
- <enumerator name="BackToFront" value="1" />
- </enum>
- <property name="position" type="QVector3D" />
- <property name="x" type="qreal" />
- <property name="y" type="qreal" />
- <property name="z" type="qreal" />
- <property name="scale" type="qreal" />
- <property name="transform" type="QGraphicsTransform3D" isList="true" />
- <property name="pretransform" type="QGraphicsTransform3D" isList="true" />
- <property name="mesh" type="QDeclarativeMesh" />
- <property name="effect" type="QDeclarativeEffect" />
- <property name="light" type="QGLLightParameters" />
- <property name="resources" type="QObject" isList="true" />
- <property name="data" type="QObject" isList="true" />
- <property name="children" type="QDeclarativeItem3D" isList="true" />
- <property name="cullFaces" type="CullFaces" />
- <property name="sortChildren" type="SortMode" />
- <property name="meshNode" type="string" />
- <property name="inheritEvents" type="bool" />
- <property name="enabled" type="bool" />
- <property name="parent" type="QDeclarativeItem3D" />
- <signal name="positionChanged" />
- <signal name="scaleChanged" />
- <signal name="rotationChanged" />
- <signal name="meshChanged" />
- <signal name="meshNodeChanged" />
- <signal name="effectChanged" />
- <signal name="lightChanged" />
- <signal name="stateChanged">
- <param type="string" />
- </signal>
- <signal name="clicked" />
- <signal name="doubleClicked" />
- <signal name="pressed" />
- <signal name="released" />
- <signal name="hoverEnter" />
- <signal name="hoverLeave" />
- <signal name="inheritEventsChanged" />
- <signal name="enabledChanged" />
- <signal name="childrenChanged" />
- <signal name="parentChanged" />
- <signal name="sortChildrenChanged" />
- <method name="update" />
- <method name="localToWorld" type="QVector3D">
- <param name="point" type="QVector3D" />
- </method>
- <method name="localToWorld" type="QVector3D" />
- <method name="worldToLocal" type="QVector3D">
- <param name="point" type="QVector3D" />
- </method>
- <method name="worldToLocal" type="QVector3D" />
- </type>
- <type name="QDeclarativeMesh" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="Mesh" />
- </exports>
- <property name="source" type="QUrl" />
- <property name="meshName" type="string" />
- <property name="options" type="string" />
- <property name="dumpInfo" type="bool" />
- <signal name="dataChanged" />
- <signal name="loaded" />
- <signal name="optionsChanged" />
- <signal name="dumpInfoChanged" />
- <method name="material" type="QObject*">
- <param name="nodeName" type="string" />
- <param name="materialName" type="string" />
- </method>
- </type>
- <type name="QGLCamera" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="Camera" />
- </exports>
- <enum name="ProjectionType">
- <enumerator name="Perspective" value="0" />
- <enumerator name="Orthographic" value="1" />
- </enum>
- <enum name="RotateOrder">
- <enumerator name="TiltPanRoll" value="0" />
- <enumerator name="TiltRollPan" value="1" />
- <enumerator name="PanTiltRoll" value="2" />
- <enumerator name="PanRollTilt" value="3" />
- <enumerator name="RollTiltPan" value="4" />
- <enumerator name="RollPanTilt" value="5" />
- </enum>
- <property name="projectionType" type="ProjectionType" />
- <property name="fieldOfView" type="qreal" />
- <property name="nearPlane" type="qreal" />
- <property name="farPlane" type="qreal" />
- <property name="viewSize" type="QSizeF" />
- <property name="minViewSize" type="QSizeF" />
- <property name="screenRotation" type="int" />
- <property name="eye" type="QVector3D" />
- <property name="upVector" type="QVector3D" />
- <property name="center" type="QVector3D" />
- <property name="eyeSeparation" type="qreal" />
- <property name="motionAdjustment" type="QVector3D" />
- <property name="adjustForAspectRatio" type="bool" />
- <signal name="projectionChanged" />
- <signal name="viewChanged" />
- <method name="translateEye">
- <param name="x" type="qreal" />
- <param name="y" type="qreal" />
- <param name="z" type="qreal" />
- </method>
- <method name="translateCenter">
- <param name="x" type="qreal" />
- <param name="y" type="qreal" />
- <param name="z" type="qreal" />
- </method>
- <method name="tiltPanRollCenter">
- <param name="tiltAngle" type="qreal" />
- <param name="panAngle" type="qreal" />
- <param name="rollAngle" type="qreal" />
- <param name="order" type="QGLCamera.RotateOrder" />
- </method>
- <method name="tiltPanRollCenter">
- <param name="tiltAngle" type="qreal" />
- <param name="panAngle" type="qreal" />
- <param name="rollAngle" type="qreal" />
- </method>
- <method name="tiltPanRollEye">
- <param name="tiltAngle" type="qreal" />
- <param name="panAngle" type="qreal" />
- <param name="rollAngle" type="qreal" />
- <param name="order" type="QGLCamera.RotateOrder" />
- </method>
- <method name="tiltPanRollEye">
- <param name="tiltAngle" type="qreal" />
- <param name="panAngle" type="qreal" />
- <param name="rollAngle" type="qreal" />
- </method>
- </type>
- <type name="QGLLightModel" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="LightModel" />
- </exports>
- <enum name="Model">
- <enumerator name="OneSided" value="0" />
- <enumerator name="TwoSided" value="1" />
- </enum>
- <enum name="ColorControl">
- <enumerator name="SingleColor" value="0" />
- <enumerator name="SeparateSpecularColor" value="1" />
- </enum>
- <enum name="ViewerPosition">
- <enumerator name="ViewerAtInfinity" value="0" />
- <enumerator name="LocalViewer" value="1" />
- </enum>
- <property name="model" type="Model" />
- <property name="colorControl" type="ColorControl" />
- <property name="viewerPosition" type="ViewerPosition" />
- <property name="ambientSceneColor" type="QColor" />
- <signal name="modelChanged" />
- <signal name="colorControlChanged" />
- <signal name="viewerPositionChanged" />
- <signal name="ambientSceneColorChanged" />
- <signal name="lightModelChanged" />
- </type>
- <type name="QGLLightParameters" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="Light" />
- </exports>
- <enum name="LightType">
- <enumerator name="Directional" value="0" />
- <enumerator name="Positional" value="1" />
- </enum>
- <property name="type" type="LightType" />
- <property name="position" type="QVector3D" />
- <property name="direction" type="QVector3D" />
- <property name="ambientColor" type="QColor" />
- <property name="diffuseColor" type="QColor" />
- <property name="specularColor" type="QColor" />
- <property name="spotDirection" type="QVector3D" />
- <property name="spotExponent" type="qreal" />
- <property name="spotAngle" type="qreal" />
- <property name="constantAttenuation" type="qreal" />
- <property name="linearAttenuation" type="qreal" />
- <property name="quadraticAttenuation" type="qreal" />
- <signal name="positionChanged" />
- <signal name="directionChanged" />
- <signal name="ambientColorChanged" />
- <signal name="diffuseColorChanged" />
- <signal name="specularColorChanged" />
- <signal name="spotDirectionChanged" />
- <signal name="spotExponentChanged" />
- <signal name="spotAngleChanged" />
- <signal name="constantAttenuationChanged" />
- <signal name="linearAttenuationChanged" />
- <signal name="quadraticAttenuationChanged" />
- <signal name="lightChanged" />
- </type>
- <type name="QGLMaterial" extends="QGLAbstractMaterial">
- <exports>
- <export module="Qt3D" version="1.0" type="Material" />
- </exports>
- <enum name="TextureCombineMode">
- <enumerator name="Modulate" value="0" />
- <enumerator name="Decal" value="1" />
- <enumerator name="Replace" value="2" />
- </enum>
- <property name="ambientColor" type="QColor" />
- <property name="diffuseColor" type="QColor" />
- <property name="specularColor" type="QColor" />
- <property name="emittedLight" type="QColor" />
- <property name="shininess" type="qreal" />
- <property name="texture" type="QGLTexture2D" />
- <property name="textureCombineMode" type="QGLMaterial.TextureCombineMode" />
- <property name="textureUrl" type="QUrl" />
- <signal name="ambientColorChanged" />
- <signal name="diffuseColorChanged" />
- <signal name="specularColorChanged" />
- <signal name="emittedLightChanged" />
- <signal name="shininessChanged" />
- <signal name="texturesChanged" />
- </type>
- <type name="QGLSceneNode" extends="QObject">
- <exports>
- <export module="Qt3D" version="1.0" type="SceneNode" />
- </exports>
- <property name="position" type="QVector3D" />
- <property name="x" type="qreal" />
- <property name="y" type="qreal" />
- <property name="z" type="qreal" />
- <property name="material" type="QGLMaterial" />
- <property name="backMaterial" type="QGLMaterial" />
- <signal name="updated" />
- <method name="clone" type="QGLSceneNode*">
- <param name="parent" type="QObject" />
- </method>
- <method name="clone" type="QGLSceneNode*" />
- <method name="cloneNoChildren" type="QGLSceneNode*">
- <param name="parent" type="QObject" />
- </method>
- <method name="cloneNoChildren" type="QGLSceneNode*" />
- <method name="allExcept" type="QGLSceneNode*">
- <param name="name" type="string" />
- <param name="parent" type="QObject" />
- </method>
- <method name="allExcept" type="QGLSceneNode*">
- <param name="name" type="string" />
- </method>
- <method name="only" type="QGLSceneNode*">
- <param name="name" type="string" />
- <param name="parent" type="QObject" />
- </method>
- <method name="only" type="QGLSceneNode*">
- <param name="name" type="string" />
- </method>
- <method name="allExcept" type="QGLSceneNode*">
- <param name="names" type="QStringList" />
- <param name="parent" type="QObject" />
- </method>
- <method name="allExcept" type="QGLSceneNode*">
- <param name="names" type="QStringList" />
- </method>
- <method name="only" type="QGLSceneNode*">
- <param name="names" type="QStringList" />
- <param name="parent" type="QObject" />
- </method>
- <method name="only" type="QGLSceneNode*">
- <param name="names" type="QStringList" />
- </method>
- </type>
- <type name="QGraphicsBillboardTransform" extends="QGraphicsTransform3D">
- <exports>
- <export module="Qt3D" version="1.0" type="BillboardTransform" />
- </exports>
- <property name="preserveUpVector" type="bool" />
- <signal name="preserveUpVectorChanged" />
- </type>
- <type name="QGraphicsLookAtTransform" extends="QGraphicsTransform3D">
- <exports>
- <export module="Qt3D" version="1.0" type="LookAt" />
- </exports>
- <property name="preserveUpVector" type="bool" />
- <property name="subject" type="QDeclarativeItem3D" />
- <signal name="preserveUpVectorChanged" />
- <signal name="subjectChanged" />
- </type>
- <type name="QGraphicsRotation3D" extends="QGraphicsTransform3D">
- <exports>
- <export module="Qt3D" version="1.0" type="Rotation3D" />
- </exports>
- <property name="origin" type="QVector3D" />
- <property name="angle" type="qreal" />
- <property name="axis" type="QVector3D" />
- <signal name="originChanged" />
- <signal name="angleChanged" />
- <signal name="axisChanged" />
- </type>
- <type name="QGraphicsTranslation3D" extends="QGraphicsTransform3D">
- <exports>
- <export module="Qt3D" version="1.0" type="Translation3D" />
- </exports>
- <property name="translate" type="QVector3D" />
- <property name="progress" type="qreal" />
- <signal name="translateChanged" />
- <signal name="progressChanged" />
- </type>
- <type name="Scale3D" extends="QGraphicsScale3D">
- <exports>
- <export module="Qt3D" version="1.0" type="Scale3D" />
- </exports>
- <property name="scale" type="QVariant" />
- <signal name="variantScaleChanged" />
- </type>
- <type name="ShaderProgram" extends="QDeclarativeEffect">
- <exports>
- <export module="Qt3D" version="1.0" type="ShaderProgram" />
- </exports>
- <property name="vertexShader" type="string" />
- <property name="fragmentShader" type="string" />
- <signal name="finishedLoading" />
- <signal name="shaderChanged" />
- <method name="markAllPropertiesDirty" />
- <method name="markPropertyDirty">
- <param name="property" type="int" />
- </method>
- </type>
- <type name="Viewport" defaultProperty="data" extends="QDeclarativeItem">
- <exports>
- <export module="Qt3D" version="1.0" type="Viewport" />
- </exports>
- <property name="picking" type="bool" />
- <property name="showPicking" type="bool" />
- <property name="navigation" type="bool" />
- <property name="fovzoom" type="bool" />
- <property name="blending" type="bool" />
- <property name="camera" type="QGLCamera" />
- <property name="light" type="QGLLightParameters" />
- <property name="lightModel" type="QGLLightModel" />
- <signal name="viewportChanged" />
- <method name="update3d" />
- <method name="objectForPoint" type="QObject*">
- <param name="x" type="qreal" />
- <param name="y" type="qreal" />
- </method>
- </type>
-</module>
diff --git a/src/imports/threed/plugins.qmltypes b/src/imports/threed/plugins.qmltypes
deleted file mode 100755
index 477bb4a9..00000000
--- a/src/imports/threed/plugins.qmltypes
+++ /dev/null
@@ -1,499 +0,0 @@
-import QtQuick.tooling 1.0
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-
-Module {
- Component {
- name: "QDeclarativeEffect"
- prototype: "QObject"
- exports: [
- "Effect 1.0"
- ]
- Property { name: "color"; type: "QColor" }
- Property { name: "useLighting"; type: "bool" }
- Property { name: "decal"; type: "bool" }
- Property { name: "blending"; type: "bool" }
- Property { name: "texture"; type: "QUrl" }
- Property { name: "textureImage"; type: "QImage" }
- Property { name: "material"; type: "QGLMaterial"; isPointer: true }
- Property { name: "progress"; type: "qreal"; isReadonly: true }
- Signal { name: "effectChanged" }
- Signal {
- name: "progressChanged"
- Parameter { name: "progress"; type: "qreal" }
- }
- }
- Component {
- name: "QDeclarativeItem3D"
- defaultProperty: "data"
- prototype: "QDeclarativeItem"
- exports: [
- "Item3D 1.0"
- ]
- Enum {
- name: "CullFace"
- values: {
- "CullDisabled": 0,
- "CullFrontFaces": 1028,
- "CullBackFaces": 1029,
- "CullAllFaces": 1032,
- "CullClockwise": 65536
- }
- }
- Enum {
- name: "CullFaces"
- values: {
- "CullDisabled": 0,
- "CullFrontFaces": 1028,
- "CullBackFaces": 1029,
- "CullAllFaces": 1032,
- "CullClockwise": 65536
- }
- }
- Enum {
- name: "SortMode"
- values: {
- "DefaultSorting": 0,
- "BackToFront": 1
- }
- }
- Property { name: "position"; type: "QVector3D" }
- Property { name: "x"; type: "qreal" }
- Property { name: "y"; type: "qreal" }
- Property { name: "z"; type: "qreal" }
- Property { name: "scale"; type: "qreal" }
- Property { name: "transform"; type: "QGraphicsTransform3D"; isList: true; isReadonly: true }
- Property { name: "pretransform"; type: "QGraphicsTransform3D"; isList: true; isReadonly: true }
- Property { name: "mesh"; type: "QDeclarativeMesh"; isPointer: true }
- Property { name: "effect"; type: "QDeclarativeEffect"; isPointer: true }
- Property { name: "light"; type: "QGLLightParameters"; isPointer: true }
- Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "children"; type: "QDeclarativeItem3D"; isList: true; isReadonly: true }
- Property { name: "cullFaces"; type: "CullFaces" }
- Property { name: "sortChildren"; type: "SortMode" }
- Property { name: "meshNode"; type: "string" }
- Property { name: "inheritEvents"; type: "bool" }
- Property { name: "enabled"; type: "bool" }
- Property { name: "parent"; type: "QDeclarativeItem3D"; isPointer: true }
- Signal { name: "positionChanged" }
- Signal { name: "scaleChanged" }
- Signal { name: "rotationChanged" }
- Signal { name: "meshChanged" }
- Signal { name: "meshNodeChanged" }
- Signal { name: "effectChanged" }
- Signal { name: "lightChanged" }
- Signal {
- name: "stateChanged"
- Parameter { type: "string" }
- }
- Signal { name: "clicked" }
- Signal { name: "doubleClicked" }
- Signal { name: "pressed" }
- Signal { name: "released" }
- Signal { name: "hoverEnter" }
- Signal { name: "hoverLeave" }
- Signal { name: "inheritEventsChanged" }
- Signal { name: "enabledChanged" }
- Signal { name: "childrenChanged" }
- Signal { name: "parentChanged" }
- Signal { name: "sortChildrenChanged" }
- Method { name: "update" }
- Method {
- name: "localToWorld"
- type: "QVector3D"
- Parameter { name: "point"; type: "QVector3D" }
- }
- Method { name: "localToWorld"; type: "QVector3D" }
- Method {
- name: "worldToLocal"
- type: "QVector3D"
- Parameter { name: "point"; type: "QVector3D" }
- }
- Method { name: "worldToLocal"; type: "QVector3D" }
- }
- Component {
- name: "QDeclarativeMesh"
- prototype: "QObject"
- exports: [
- "Mesh 1.0"
- ]
- Property { name: "source"; type: "QUrl" }
- Property { name: "meshName"; type: "string" }
- Property { name: "options"; type: "string" }
- Property { name: "dumpInfo"; type: "bool" }
- Signal { name: "dataChanged" }
- Signal { name: "loaded" }
- Signal { name: "optionsChanged" }
- Signal { name: "dumpInfoChanged" }
- Method {
- name: "material"
- type: "QObject*"
- Parameter { name: "nodeName"; type: "string" }
- Parameter { name: "materialName"; type: "string" }
- }
- }
- Component {
- name: "QGLAbstractMaterial"
- prototype: "QObject"
- Signal { name: "materialChanged" }
- }
- Component {
- name: "QGLCamera"
- prototype: "QObject"
- exports: [
- "Camera 1.0"
- ]
- Enum {
- name: "ProjectionType"
- values: {
- "Perspective": 0,
- "Orthographic": 1
- }
- }
- Enum {
- name: "RotateOrder"
- values: {
- "TiltPanRoll": 0,
- "TiltRollPan": 1,
- "PanTiltRoll": 2,
- "PanRollTilt": 3,
- "RollTiltPan": 4,
- "RollPanTilt": 5
- }
- }
- Property { name: "projectionType"; type: "ProjectionType" }
- Property { name: "fieldOfView"; type: "qreal" }
- Property { name: "nearPlane"; type: "qreal" }
- Property { name: "farPlane"; type: "qreal" }
- Property { name: "viewSize"; type: "QSizeF" }
- Property { name: "minViewSize"; type: "QSizeF" }
- Property { name: "screenRotation"; type: "int" }
- Property { name: "eye"; type: "QVector3D" }
- Property { name: "upVector"; type: "QVector3D" }
- Property { name: "center"; type: "QVector3D" }
- Property { name: "eyeSeparation"; type: "qreal" }
- Property { name: "motionAdjustment"; type: "QVector3D" }
- Property { name: "adjustForAspectRatio"; type: "bool" }
- Signal { name: "projectionChanged" }
- Signal { name: "viewChanged" }
- Method {
- name: "translateEye"
- Parameter { name: "x"; type: "qreal" }
- Parameter { name: "y"; type: "qreal" }
- Parameter { name: "z"; type: "qreal" }
- }
- Method {
- name: "translateCenter"
- Parameter { name: "x"; type: "qreal" }
- Parameter { name: "y"; type: "qreal" }
- Parameter { name: "z"; type: "qreal" }
- }
- Method {
- name: "tiltPanRollCenter"
- Parameter { name: "tiltAngle"; type: "qreal" }
- Parameter { name: "panAngle"; type: "qreal" }
- Parameter { name: "rollAngle"; type: "qreal" }
- Parameter { name: "order"; type: "QGLCamera::RotateOrder" }
- }
- Method {
- name: "tiltPanRollCenter"
- Parameter { name: "tiltAngle"; type: "qreal" }
- Parameter { name: "panAngle"; type: "qreal" }
- Parameter { name: "rollAngle"; type: "qreal" }
- }
- Method {
- name: "tiltPanRollEye"
- Parameter { name: "tiltAngle"; type: "qreal" }
- Parameter { name: "panAngle"; type: "qreal" }
- Parameter { name: "rollAngle"; type: "qreal" }
- Parameter { name: "order"; type: "QGLCamera::RotateOrder" }
- }
- Method {
- name: "tiltPanRollEye"
- Parameter { name: "tiltAngle"; type: "qreal" }
- Parameter { name: "panAngle"; type: "qreal" }
- Parameter { name: "rollAngle"; type: "qreal" }
- }
- }
- Component {
- name: "QGLLightModel"
- prototype: "QObject"
- exports: [
- "LightModel 1.0"
- ]
- Enum {
- name: "Model"
- values: {
- "OneSided": 0,
- "TwoSided": 1
- }
- }
- Enum {
- name: "ColorControl"
- values: {
- "SingleColor": 0,
- "SeparateSpecularColor": 1
- }
- }
- Enum {
- name: "ViewerPosition"
- values: {
- "ViewerAtInfinity": 0,
- "LocalViewer": 1
- }
- }
- Property { name: "model"; type: "Model" }
- Property { name: "colorControl"; type: "ColorControl" }
- Property { name: "viewerPosition"; type: "ViewerPosition" }
- Property { name: "ambientSceneColor"; type: "QColor" }
- Signal { name: "modelChanged" }
- Signal { name: "colorControlChanged" }
- Signal { name: "viewerPositionChanged" }
- Signal { name: "ambientSceneColorChanged" }
- Signal { name: "lightModelChanged" }
- }
- Component {
- name: "QGLLightParameters"
- prototype: "QObject"
- exports: [
- "Light 1.0"
- ]
- Enum {
- name: "LightType"
- values: {
- "Directional": 0,
- "Positional": 1
- }
- }
- Property { name: "type"; type: "LightType"; isReadonly: true }
- Property { name: "position"; type: "QVector3D" }
- Property { name: "direction"; type: "QVector3D" }
- Property { name: "ambientColor"; type: "QColor" }
- Property { name: "diffuseColor"; type: "QColor" }
- Property { name: "specularColor"; type: "QColor" }
- Property { name: "spotDirection"; type: "QVector3D" }
- Property { name: "spotExponent"; type: "qreal" }
- Property { name: "spotAngle"; type: "qreal" }
- Property { name: "constantAttenuation"; type: "qreal" }
- Property { name: "linearAttenuation"; type: "qreal" }
- Property { name: "quadraticAttenuation"; type: "qreal" }
- Signal { name: "positionChanged" }
- Signal { name: "directionChanged" }
- Signal { name: "ambientColorChanged" }
- Signal { name: "diffuseColorChanged" }
- Signal { name: "specularColorChanged" }
- Signal { name: "spotDirectionChanged" }
- Signal { name: "spotExponentChanged" }
- Signal { name: "spotAngleChanged" }
- Signal { name: "constantAttenuationChanged" }
- Signal { name: "linearAttenuationChanged" }
- Signal { name: "quadraticAttenuationChanged" }
- Signal { name: "lightChanged" }
- }
- Component {
- name: "QGLMaterial"
- prototype: "QGLAbstractMaterial"
- exports: [
- "Material 1.0"
- ]
- Enum {
- name: "TextureCombineMode"
- values: {
- "Modulate": 0,
- "Decal": 1,
- "Replace": 2
- }
- }
- Property { name: "ambientColor"; type: "QColor" }
- Property { name: "diffuseColor"; type: "QColor" }
- Property { name: "specularColor"; type: "QColor" }
- Property { name: "emittedLight"; type: "QColor" }
- Property { name: "shininess"; type: "qreal" }
- Property { name: "texture"; type: "QGLTexture2D"; isPointer: true }
- Property { name: "textureCombineMode"; type: "QGLMaterial::TextureCombineMode" }
- Property { name: "textureUrl"; type: "QUrl" }
- Signal { name: "ambientColorChanged" }
- Signal { name: "diffuseColorChanged" }
- Signal { name: "specularColorChanged" }
- Signal { name: "emittedLightChanged" }
- Signal { name: "shininessChanged" }
- Signal { name: "texturesChanged" }
- }
- Component {
- name: "QGLSceneNode"
- prototype: "QObject"
- exports: [
- "SceneNode 1.0"
- ]
- Property { name: "position"; type: "QVector3D" }
- Property { name: "x"; type: "qreal" }
- Property { name: "y"; type: "qreal" }
- Property { name: "z"; type: "qreal" }
- Property { name: "material"; type: "QGLMaterial"; isPointer: true }
- Property { name: "backMaterial"; type: "QGLMaterial"; isPointer: true }
- Signal { name: "updated" }
- Method {
- name: "clone"
- type: "QGLSceneNode*"
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method { name: "clone"; type: "QGLSceneNode*" }
- Method {
- name: "cloneNoChildren"
- type: "QGLSceneNode*"
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method { name: "cloneNoChildren"; type: "QGLSceneNode*" }
- Method {
- name: "allExcept"
- type: "QGLSceneNode*"
- Parameter { name: "name"; type: "string" }
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "allExcept"
- type: "QGLSceneNode*"
- Parameter { name: "name"; type: "string" }
- }
- Method {
- name: "only"
- type: "QGLSceneNode*"
- Parameter { name: "name"; type: "string" }
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "only"
- type: "QGLSceneNode*"
- Parameter { name: "name"; type: "string" }
- }
- Method {
- name: "allExcept"
- type: "QGLSceneNode*"
- Parameter { name: "names"; type: "QStringList" }
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "allExcept"
- type: "QGLSceneNode*"
- Parameter { name: "names"; type: "QStringList" }
- }
- Method {
- name: "only"
- type: "QGLSceneNode*"
- Parameter { name: "names"; type: "QStringList" }
- Parameter { name: "parent"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "only"
- type: "QGLSceneNode*"
- Parameter { name: "names"; type: "QStringList" }
- }
- }
- Component {
- name: "QGraphicsBillboardTransform"
- prototype: "QGraphicsTransform3D"
- exports: [
- "BillboardTransform 1.0"
- ]
- Property { name: "preserveUpVector"; type: "bool" }
- Signal { name: "preserveUpVectorChanged" }
- }
- Component {
- name: "QGraphicsLookAtTransform"
- prototype: "QGraphicsTransform3D"
- exports: [
- "LookAt 1.0"
- ]
- Property { name: "preserveUpVector"; type: "bool" }
- Property { name: "subject"; type: "QDeclarativeItem3D"; isPointer: true }
- Signal { name: "preserveUpVectorChanged" }
- Signal { name: "subjectChanged" }
- }
- Component {
- name: "QGraphicsRotation3D"
- prototype: "QGraphicsTransform3D"
- exports: [
- "Rotation3D 1.0"
- ]
- Property { name: "origin"; type: "QVector3D" }
- Property { name: "angle"; type: "qreal" }
- Property { name: "axis"; type: "QVector3D" }
- Signal { name: "originChanged" }
- Signal { name: "angleChanged" }
- Signal { name: "axisChanged" }
- }
- Component {
- name: "QGraphicsScale3D"
- prototype: "QGraphicsTransform3D"
- Property { name: "origin"; type: "QVector3D" }
- Property { name: "scale"; type: "QVector3D" }
- Signal { name: "originChanged" }
- Signal { name: "scaleChanged" }
- }
- Component {
- name: "QGraphicsTransform3D"
- prototype: "QObject"
- Signal { name: "transformChanged" }
- }
- Component {
- name: "QGraphicsTranslation3D"
- prototype: "QGraphicsTransform3D"
- exports: [
- "Translation3D 1.0"
- ]
- Property { name: "translate"; type: "QVector3D" }
- Property { name: "progress"; type: "qreal" }
- Signal { name: "translateChanged" }
- Signal { name: "progressChanged" }
- }
- Component {
- name: "Scale3D"
- prototype: "QGraphicsScale3D"
- exports: [
- "Scale3D 1.0"
- ]
- Property { name: "scale"; type: "QVariant" }
- Signal { name: "variantScaleChanged" }
- }
- Component {
- name: "ShaderProgram"
- prototype: "QDeclarativeEffect"
- exports: [
- "ShaderProgram 1.0"
- ]
- Property { name: "vertexShader"; type: "string" }
- Property { name: "fragmentShader"; type: "string" }
- Signal { name: "finishedLoading" }
- Signal { name: "shaderChanged" }
- Method { name: "markAllPropertiesDirty" }
- Method {
- name: "markPropertyDirty"
- Parameter { name: "property"; type: "int" }
- }
- }
- Component {
- name: "Viewport"
- defaultProperty: "data"
- prototype: "QDeclarativeItem"
- exports: [
- "Viewport 1.0"
- ]
- Property { name: "picking"; type: "bool" }
- Property { name: "showPicking"; type: "bool" }
- Property { name: "navigation"; type: "bool" }
- Property { name: "blending"; type: "bool" }
- Property { name: "camera"; type: "QGLCamera"; isPointer: true }
- Property { name: "light"; type: "QGLLightParameters"; isPointer: true }
- Property { name: "lightModel"; type: "QGLLightModel"; isPointer: true }
- Signal { name: "viewportChanged" }
- Method { name: "update3d" }
- Method {
- name: "objectForPoint"
- type: "QObject*"
- Parameter { name: "x"; type: "qreal" }
- Parameter { name: "y"; type: "qreal" }
- }
- }
-}
diff --git a/src/imports/threed/qgraphicslookattransform.cpp b/src/imports/threed/qgraphicslookattransform.cpp
deleted file mode 100644
index e3772b94..00000000
--- a/src/imports/threed/qgraphicslookattransform.cpp
+++ /dev/null
@@ -1,517 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicslookattransform.h"
-#include "qgraphicsrotation3d.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsLookAtTransform
- \brief The QGraphicsLookAtTransform class implements a transformation
- that causes an Item3D to orient to face another Item3D.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- Sometimes it can be useful to make an object face towards another object,
- wherever it might be located. This is useful for objects like cameras,
- lights, arrows, faces etc.
-
- Another common use is called "billboarding", where a quad is always
- oriented to face the camera.
-*/
-
-/*!
- \qmlclass LookAtTransform QGraphicsLookAtTransform
- \brief The LookAtTransform item implements a transformation that causes objects to face the camera.
- \since 4.8
- \ingroup qt3d::qml3d
-
- Sometimes it can be useful to make an object face towards another object,
- wherever it might be located. This is useful for objects like cameras,
- lights, arrows, faces etc.
-
- Another common use is called "billboarding", where a quad is always
- oriented to face the camera. In QML, this can be achieved as follows:
-
- \code
- Camera3D camera
- Item3D {
- mesh: Mesh { source: "pane.obj" }
- position: Qt.vector3d(2, 0, -20)
- transform: LookAtTransform { worldPosition - camera.worldPosition }
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-
- Because the lookAt transformation will override many other transformations
- ont the matrix, it will usually be the last element in the \c transform
- list (transformations are applied to the matrix in reverse order of their
- appearance in \c transform):
-
- \code
- Item3D {
- mesh: Mesh { source: "pane.obj" }
- position: Qt.vector3d(2, 0, -20)
- transform: [
- Scale3D { scale: 0.5 },
- Rotation3D { angle: 30 },
- LookAtTransform { worldPosition - camera.worldPosition }
- ]
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-
- Typically, orientation as well as facing is important. For example, a face
- that does not remain basically upright will look very odd indeed as it
- tracks a subject. The lookAt transform will always rotate first around the
- local y axis, and secondarily around the local x axis, around an origin of
- (0,0,0).
-
- If rotation around a different axis or origin is desired, place the
- Item3D to be rotated inside a new parent Item3D. Apply rotations the
- and translations to the original Item3D such that the desired "front"
- matches the new parent Item3d's positive z direction and the left to right
- matches the parent's x-axis, and then apply the LookAt transform to the
- new parent item.
-
- \code
- Item3D {
- position: Qt.vector3d(0,0,4)
- transform: LookAt { subject: subjectPenguin }
-
- Item3D {
- id: lookAwayMonkey
- mesh: Mesh { source: "meshes/monkey.3ds" }
- transform: Rotation3D { axis: Qt.vector3d(0,1,0); angle: 180 }
- }
- }
- \endcode
-
- By default the LookAt transform will cause the object to
- face directly at the subject no matter how the world co-ordinate
- system is rotated. Sometimes it is useful to limit the lookAt to only
- one axis of rotation - for example, a tank with a turret and barrel that
- each have only one degree of freedom.
- This is achieved by using the preserveUpVector property:
-
- \code
- Pane {
- position: Qt.vector3d(2, 0, -20)
- transform: LookAtTransform { preserveUpVector: true }
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-*/
-
-/*!
- \internal
-*/
-static QMatrix4x4* cheatingSphericalBillboard(QMatrix4x4 *matrix)
-{
- // Replace the top-left 3x3 of the matrix with the identity.
- // The technique is "Cheating Spherical Billboards", described here:
- // http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat
- (*matrix)(0, 0) = 1.0f;
- (*matrix)(0, 1) = 0.0f;
- (*matrix)(0, 2) = 0.0f;
- (*matrix)(1, 0) = 0.0f;
- (*matrix)(1, 1) = 1.0f;
- (*matrix)(1, 2) = 0.0f;
- (*matrix)(2, 0) = 0.0f;
- (*matrix)(2, 1) = 0.0f;
- (*matrix)(2, 2) = 1.0f;
-
- return matrix;
-};
-
-/*!
- \internal
-*/
-static QMatrix4x4* cheatingCylindricalBillboard(QMatrix4x4 *matrix)
-{
- // Replace some of the top-left 3x3 of the matrix with the identity,
- // but leave the up vector component in the second column as-is.
- // The technique is "Cheating Cylindrical Billboards", described here:
- // http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat1
- (*matrix)(0, 0) = 1.0f;
- (*matrix)(0, 2) = 0.0f;
- (*matrix)(1, 0) = 0.0f;
- (*matrix)(1, 2) = 0.0f;
- (*matrix)(2, 0) = 0.0f;
- (*matrix)(2, 2) = 1.0f;
-
- return matrix;
-};
-
-#define RADS_TO_DEGREES (180.0 / M_PI)
-
-struct LookAtRotationCache {
- QGraphicsRotation3D primaryRotation;
- QGraphicsRotation3D secondaryRotation;
-};
-
-class QGraphicsLookAtTransformPrivate
-{
-public:
- QGraphicsLookAtTransformPrivate(QGraphicsLookAtTransform* _lookAt);
- QGraphicsLookAtTransform* lookAt;
- void determineOriginItem();
- void calculateRotationValues() const;
- QVector3D relativePosition(QDeclarativeItem3D* originItem, QDeclarativeItem3D* subject) const;
-
- bool preserveUpVector;
- QDeclarativeItem3D* originItem;
- QDeclarativeItem3D* subject;
- mutable LookAtRotationCache rotationCache;
- mutable bool rotationCacheDirty;
-
-};
-
-QGraphicsLookAtTransformPrivate::QGraphicsLookAtTransformPrivate(QGraphicsLookAtTransform* _lookAt) :
- lookAt(_lookAt), preserveUpVector(false), originItem(0), subject(0)
-{
-}
-
-void QGraphicsLookAtTransformPrivate::determineOriginItem()
-{
- QObject* workingObject = lookAt->parent();
- while (qobject_cast<QDeclarativeItem3D*>(workingObject) == 0 &&
- workingObject != 0)
- {
- workingObject = workingObject->parent();
- }
-
- originItem = qobject_cast<QDeclarativeItem3D*>(workingObject);
- if (!originItem)
- qWarning() << "LookAt transform requires an Item3D ancestor";
-}
-
-QVector3D QGraphicsLookAtTransformPrivate::relativePosition(QDeclarativeItem3D* originItem, QDeclarativeItem3D* subject) const
-{
- QVector3D result = originItem->worldToLocal(subject->localToWorld());
- return result;
-
-}
-
-/*! \internal
- Calculate the actual rotation values for the transform.
-
- Note this function has to be const to be called within applyTo(), but
- modifies the mutable rotationCache and rotationCacheDirty values.
-*/
-void QGraphicsLookAtTransformPrivate::calculateRotationValues() const
-{
- QVector3D forwards(0, 0, 1);
- rotationCache.primaryRotation.setAngle(0);
- rotationCache.secondaryRotation.setAngle(0);
- rotationCacheDirty = false;
-
- if (subject == 0 || originItem == 0)
- {
- if (subject == 0)
- qWarning() << "LookAt transform got null subject";
- if (originItem == 0)
- qWarning() << "LookAt transform got null originItem";
- rotationCache.primaryRotation.setAxis(QVector3D(0,1,0));
- rotationCache.primaryRotation.setAngle(0);
- rotationCache.secondaryRotation.setAxis(QVector3D(1,0,0));
- rotationCache.secondaryRotation.setAngle(0);
- return;
- }
-
- // Calculate the lookat vector in the local frame:
- QVector3D relativePositionVector = relativePosition(originItem, subject);
-
- // Project the relative position into the xz plane:
- QVector3D subjectProjection = relativePositionVector;
- subjectProjection.setY(0);
- subjectProjection.normalize();
- QVector3D primaryRotationAxis;
-
- if (!subjectProjection.isNull())
- {
- primaryRotationAxis = QVector3D::crossProduct(forwards, subjectProjection);
- // Fix rotational axis for positions along z axis
- if (primaryRotationAxis.length() == 0)
- {
- primaryRotationAxis = QVector3D(0,1,0);
- }
-
- qreal angleCosine =
- QVector3D::dotProduct(forwards, subjectProjection);
- qreal angle = qAcos(angleCosine);
-
- rotationCache.primaryRotation.setAxis(primaryRotationAxis);
- rotationCache.primaryRotation.setAngle(angle * RADS_TO_DEGREES );
- } else {
- // Target is directly above or below, so zero primary rotation
- rotationCache.primaryRotation.setAxis(QVector3D(0,1,0));
- rotationCache.primaryRotation.setAngle(0);
- }
-
- relativePositionVector.normalize();
-
- qreal secondaryAngleCosine = QVector3D::dotProduct( subjectProjection,
- relativePositionVector);
- // Sanity check in case of rounding errors
- if (secondaryAngleCosine <= 1.0 && secondaryAngleCosine >= -1.0)
- {
- if (relativePositionVector.y() < 0)
- rotationCache.secondaryRotation.setAxis(QVector3D(1,0,0));
- else
- rotationCache.secondaryRotation.setAxis(QVector3D(-1,0,0));
- rotationCache.secondaryRotation.setAngle(qAcos(secondaryAngleCosine)*RADS_TO_DEGREES);
- } else {
- rotationCache.secondaryRotation.setAxis(QVector3D(1,0,0));
- rotationCache.secondaryRotation.setAngle(0.0);
- }
-}
-
-/*!
- Construct a lookAt transform and attach it to \a parent.
-*/
-QGraphicsLookAtTransform::QGraphicsLookAtTransform(QObject *parent)
- : QGraphicsTransform3D(parent), d_ptr(new QGraphicsLookAtTransformPrivate(this))
-{
-}
-
-/*!
- Destroy this lookAt transform.
-*/
-QGraphicsLookAtTransform::~QGraphicsLookAtTransform()
-{
-}
-
-/*!
- \property QGraphicsLookAtTransform::preserveUpVector
- \brief true to preserve the up orientation.
-
- This property indicates whether the transform should rotate around a second
- axis to face directly at the subject (when the subject is the camera, this
- is known as "spherical billboarding").
-
- If the value for this property is true, then the object will have
- its up vector's orientation preserved, rotating around only the y-axis and
- not directly facing the subject unless it happens to fall on the correct
- plane (when the subject is the camera, this is known as known as
- "cylindrical billboarding").
-
- The default value for this property is false.
-*/
-
-/*!
- \qmlproperty bool LookatTransform::preserveUpVector
-
- This property indicates whether the transform should rotate around a second
- axis to face directly at the subject (known as a "spherical look-at").
-
- If the value for this property is true, then the object will have
- its y-axis' orientation preserved, rotating around only this axis and
- not directly facing the subject unless it happens to fall on the correct
- plane (known as a "cylindrical look-at").
-
- The default value for this property is false.
-*/
-
-bool QGraphicsLookAtTransform::preserveUpVector() const
-{
- Q_D(const QGraphicsLookAtTransform);
- return d->preserveUpVector;
-}
-
-void QGraphicsLookAtTransform::setPreserveUpVector(bool value)
-{
- Q_D(QGraphicsLookAtTransform);
- if (d->preserveUpVector != value) {
- d->preserveUpVector = value;
- d->rotationCacheDirty = true;
- emit preserveUpVectorChanged();
- emit transformChanged();
- }
-}
-
-/*!
- \property QGraphicsLookAtTransform::subject
- \brief The local-relative coordinates that are being looked at
-
- This property indicates what this transform is trying to look at. After
- applying the transformation.
-
- Forwards is always considered to be in the direction of the positive z axis
- in local space, and up is always considered to be the positive y axis, and
- rotation is always around the position (0,0,0) in local space (although
- any values can be emulated by applying the LookAt transformation to a
- parent Item3D, and then applying transformations relative to that parent).
-
- If no subject is set, no transformation is applied.
-*/
-
-/*!
- \qmlproperty bool LookatTransform::preserveUpVector
-
- This property indicates whether the transform should rotate around a second
- axis to face directly at the subject (known as a "spherical look-at").
-
- If the value for this property is true, then the object will have
- its y-axis' orientation preserved, rotating around only this axis and
- not directly facing the subject unless it happens to fall on the correct
- plane (when the subject is the camera, this is known as a
- "cylindrical look-at").
-
- The default value for this property is false.
-*/
-
-/*!
- \fn void QGraphicsLookAtTransform::subjectChanged()
-
- Signal that is emitted when subject() changes.
-*/
-
-
-QDeclarativeItem3D* QGraphicsLookAtTransform::subject() const
-{
- Q_D(const QGraphicsLookAtTransform);
- return d->subject;
-}
-
-void QGraphicsLookAtTransform::setSubject(QDeclarativeItem3D* value)
-{
- Q_D(QGraphicsLookAtTransform);
- if (d->subject != value)
- {
- // Listen for changes on the subject and it's ancestors that mean the
- // lookAt transform needs to be recalculated
- disconnect(this, SLOT(subjectPositionChanged()));
- d->subject = value;
- QDeclarativeItem3D* ancestorItem = d->subject;
- while (ancestorItem != 0)
- {
- // listen for changes directly on the item, changes on it's
- // transforms property, or through reparenting
- connect(ancestorItem, SIGNAL(positionChanged()), this, SLOT(subjectPositionChanged()));
- connect(ancestorItem, SIGNAL(rotationChanged()), this, SLOT(subjectPositionChanged()));
- connect(ancestorItem, SIGNAL(scaleChanged()), this, SLOT(subjectPositionChanged()));
- connect(ancestorItem, SIGNAL(parentChanged()), this, SLOT(ancestryChanged()));
- QDeclarativeListProperty<QGraphicsTransform3D> transforms =
- ancestorItem->transform();
-
- for (int i=0; i < transforms.count(&transforms) ; i++)
- {
- QGraphicsTransform3D* transform = transforms.at(&transforms, i);
- connect(transform, SIGNAL(transformChanged()),
- this, SLOT(subjectPositionChanged()));
- }
-
- ancestorItem = qobject_cast<QDeclarativeItem3D*> (ancestorItem->parent());
- };
-
- d->rotationCacheDirty = true;
- d->determineOriginItem();
- emit subjectChanged();
- emit transformChanged();
- }
-};
-
-void QGraphicsLookAtTransform::subjectPositionChanged()
-{
- Q_D(QGraphicsLookAtTransform);
- d->rotationCacheDirty = true;
-}
-
-void QGraphicsLookAtTransform::ancestryChanged()
-{
- Q_D(QGraphicsLookAtTransform);
- d->determineOriginItem();
- d->rotationCacheDirty = true;
-}
-
-/*!
- \internal
-*/
-void QGraphicsLookAtTransform::applyTo(QMatrix4x4 *matrix) const
-{
- Q_D(const QGraphicsLookAtTransform);
- bool cameraTest = false;
- bool animationTest = false;
- // If we're looking at the camera, and not animating,
- // we can use a cheap cheat
- if (cameraTest && !animationTest)
- {
- if (!d->preserveUpVector)
- cheatingSphericalBillboard(matrix);
- else
- cheatingCylindricalBillboard(matrix);
- matrix->optimize();
- return;
- }
-
- if (d->rotationCacheDirty)
- d->calculateRotationValues();
-
- d->rotationCache.primaryRotation.applyTo(matrix);
- // then, if preserveVector is not set, perform a second rotation
- // around the x-axis
- if (!preserveUpVector())
- d->rotationCache.secondaryRotation.applyTo(matrix);
-}
-
-/*!
- \internal
-*/
-QGraphicsTransform3D *QGraphicsLookAtTransform::clone(QObject *parent) const
-{
- Q_D(const QGraphicsLookAtTransform);
- QGraphicsLookAtTransform *copy = new QGraphicsLookAtTransform(parent);
- copy->setPreserveUpVector(d->preserveUpVector);
- copy->setSubject(d->subject);
- return copy;
-}
-
-/*!
- \fn void QGraphicsLookAtTransform::preserveUpVectorChanged()
-
- Signal that is emitted when preserveUpVector() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/imports/threed/qgraphicslookattransform.h b/src/imports/threed/qgraphicslookattransform.h
deleted file mode 100644
index b578dff5..00000000
--- a/src/imports/threed/qgraphicslookattransform.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSLOOKATTRANSFORM_H
-#define QGRAPHICSLOOKATTRANSFORM_H
-
-#include "qgraphicstransform3d.h"
-#include "qdeclarativeitem3d.h"
-
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsLookAtTransformPrivate;
-
-class QGraphicsLookAtTransform : public QGraphicsTransform3D
-{
- Q_OBJECT
- Q_PROPERTY(bool preserveUpVector READ preserveUpVector WRITE setPreserveUpVector NOTIFY preserveUpVectorChanged)
- Q_PROPERTY(QDeclarativeItem3D* subject READ subject WRITE setSubject NOTIFY subjectChanged )
-public:
- QGraphicsLookAtTransform(QObject *parent = 0);
- ~QGraphicsLookAtTransform();
-
- bool preserveUpVector() const;
- void setPreserveUpVector(bool value);
-
- QDeclarativeItem3D* subject() const;
- void setSubject(QDeclarativeItem3D* value);
-
- void applyTo(QMatrix4x4 *matrix) const;
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-private Q_SLOTS:
- void subjectPositionChanged();
- void ancestryChanged();
-
-Q_SIGNALS:
- void preserveUpVectorChanged();
- void subjectChanged();
-
-private:
- QScopedPointer<QGraphicsLookAtTransformPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGraphicsLookAtTransform)
- Q_DECLARE_PRIVATE(QGraphicsLookAtTransform)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/imports/threed/qmldir b/src/imports/threed/qmldir
deleted file mode 100644
index 773d9a63..00000000
--- a/src/imports/threed/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin qthreedqmlplugin
diff --git a/src/imports/threed/qt3dnamespace.cpp b/src/imports/threed/qt3dnamespace.cpp
deleted file mode 100644
index 34878cd2..00000000
--- a/src/imports/threed/qt3dnamespace.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qt3dnamespace.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Qt3D Qt3DNamespace
- \brief The QML global object Qt3D provides useful functions for 3D applications.
- \ingroup qt3d::qml3d
-*/
-
-/*!
- \qmlmethod Qt3D::vector2d(real x, real y)
- Returns a Vector2D with the specified \c x and \c y.
-*/
-
-QVector2D Qt3DNamespace::vector2d(qreal x, qreal y)
-{
- return QVector2D(x, y);
-}
-
-/*!
- \qmlmethod Qt3D::vector4d(real x, real y, real z, real w)
- Returns a Vector4D with the specified \c x, \c y, \c z, and \c w.
-*/
-
-QVector4D Qt3DNamespace::vector4d(qreal x, qreal y, qreal z, qreal w)
-{
- return QVector4D(x, y, z, w);
-}
-
-/*!
- \qmlmethod Qt3D::quaternion(real scalar, real x, real y, real z)
- Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z.
-*/
-
-QQuaternion Qt3DNamespace::quaternion(qreal scalar, qreal x, qreal y, qreal z)
-{
- return QQuaternion(scalar, x, y, z);
-}
-
-/*!
- \qmlmethod Qt3D::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44)
- Returns a Matrix4x4 with the specified 16 components, which are specified
- in row-major order.
-*/
-
-QMatrix4x4 Qt3DNamespace::matrix4x4
- (qreal m11, qreal m12, qreal m13, qreal m14,
- qreal m21, qreal m22, qreal m23, qreal m24,
- qreal m31, qreal m32, qreal m33, qreal m34,
- qreal m41, qreal m42, qreal m43, qreal m44)
-{
- return QMatrix4x4(m11, m12, m13, m14,
- m21, m22, m23, m24,
- m31, m32, m33, m34,
- m41, m42, m43, m44);
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/threed/qt3dnamespace.h b/src/imports/threed/qt3dnamespace.h
deleted file mode 100644
index de65a070..00000000
--- a/src/imports/threed/qt3dnamespace.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QT3DNAMESPACE_H
-#define QT3DNAMESPACE_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qvector2d.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qquaternion.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Qt3DNamespace : public QObject
-{
- Q_OBJECT
-public:
- Qt3DNamespace(QObject *parent = 0) : QObject(parent) {}
- ~Qt3DNamespace() {}
-
-public Q_SLOTS:
- QVector2D vector2d(qreal x, qreal y);
- QVector4D vector4d(qreal x, qreal y, qreal z, qreal w);
- QQuaternion quaternion(qreal scalar, qreal x, qreal y, qreal z);
- QMatrix4x4 matrix4x4(qreal m11, qreal m12, qreal m13, qreal m14,
- qreal m21, qreal m22, qreal m23, qreal m24,
- qreal m31, qreal m32, qreal m33, qreal m34,
- qreal m41, qreal m42, qreal m43, qreal m44);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT3DNAMESPACE_H
diff --git a/src/imports/threed/scale3d.cpp b/src/imports/threed/scale3d.cpp
deleted file mode 100644
index 7b2ede95..00000000
--- a/src/imports/threed/scale3d.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "scale3d.h"
-
-QT_BEGIN_NAMESPACE
-
-void Scale3D::setScale(const QVariant &value)
-{
- QVector3D newScale;
- if (value.type() == QVariant::Vector3D) {
- newScale = value.value<QVector3D>();
- } else {
- bool ok = false;
- double val = value.toDouble(&ok);
- if (!ok) {
- qWarning("Scale3D: scale value is not a vector3D or single floating-point value");
- return;
- }
- newScale = QVector3D(qreal(val), qreal(val), qreal(val));
- }
- if (newScale != QGraphicsScale3D::scale()) {
- QGraphicsScale3D::setScale(newScale);
- emit variantScaleChanged();
- }
-}
-
-QGraphicsTransform3D *Scale3D::clone(QObject *parent) const
-{
- Scale3D *copy = new Scale3D(parent);
- copy->setOrigin(origin());
- copy->setScale(scale());
- return copy;
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/threed/scale3d.h b/src/imports/threed/scale3d.h
deleted file mode 100644
index a648bae2..00000000
--- a/src/imports/threed/scale3d.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SCALE3D_H
-#define SCALE3D_H
-
-#include "qgraphicsscale3d.h"
-
-#include <QtCore/qvariant.h>
-#include <QtDeclarative/qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Scale3D : public QGraphicsScale3D
-{
- Q_OBJECT
- Q_PROPERTY(QVariant scale READ scale WRITE setScale NOTIFY variantScaleChanged)
-public:
- Scale3D(QObject *parent = 0) : QGraphicsScale3D(parent) {}
- ~Scale3D() {}
-
- QVariant scale() const { return QGraphicsScale3D::scale(); }
- void setScale(const QVariant &value);
-
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-Q_SIGNALS:
- void variantScaleChanged();
-
-private:
- Q_DISABLE_COPY(Scale3D)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Scale3D)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/imports/threed/shaderprogram.cpp b/src/imports/threed/shaderprogram.cpp
deleted file mode 100644
index 7b775b5b..00000000
--- a/src/imports/threed/shaderprogram.cpp
+++ /dev/null
@@ -1,979 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "shaderprogram.h"
-#include "shaderprogram_p.h"
-#include "qglabstracteffect.h"
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QWeakPointer>
-
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QFile>
-
-#include "qglscenenode.h"
-/*!
- \qmlclass ShaderProgram ShaderProgram
- \brief The ShaderProgram item is derivative class of the more general Effect class in QML/3d.
- Whereas the Effect class provides support for standard effects under OpenGL, the ShaderProgramEffect supports effects based on custom shader programs for the GPU.
- \since 4.8
- \ingroup qt3d::qml3d
- \inherits Effect
-
- The ShaderProgram class provides Qml/3d users with the ability to use a QGLShaderProgram within the
- logical context of the normal \l Effect class provided by Qml/3d.
-
- If the system does not support shaders, then ShaderProgram will
- behave the same as \l Effect, with support for simple lit
- materials only.
-
- \section1 Attributes
-
- ShaderProgram provides a standard set of 8 vertex attributes that
- can be provided via the geometry \l Mesh:
-
- \table
- \header \o Shader Variable \o Mesh Attribute \o Purpose
- \row \o \c qt_Vertex \o QGL::Position
- \o The primary position of the vertex.
- \row \o \c qt_Normal \o QGL::Normal
- \o The normal at each vertex, for lit material effects.
- \row \o \c qt_Color \o QGL::Color
- \o The color at each vertex, for per-vertex color effects.
- \row \o \c qt_MultiTexCoord0 \o QGL::TextureCoord0
- \o The texture co-ordinate at each vertex for texture unit 0.
- \row \o \c qt_MultiTexCoord1 \o QGL::TextureCoord1
- \o Secondary texture co-ordinate at each vertex.
- \row \o \c qt_MultiTexCoord2 \o QGL::TextureCoord2
- \o Tertiary texture co-ordinate at each vertex.
- \row \o \c qt_Custom0 \o QGL::CustomVertex0
- \o First custom vertex attribute that can be used for any
- user-defined purpose.
- \row \o \c qt_Custom1 \o QGL::CustomVertex1
- \o Second custom vertex attribute that can be used for any
- user-defined purpose.
- \endtable
-
- These attributes are used in the vertexShader, as in the following
- example of a simple texture shader:
-
- \code
- attribute highp vec4 qt_Vertex;
- attribute highp vec4 qt_MultiTexCoord0;
- uniform mediump mat4 qt_ModelViewProjectionMatrix;
- varying highp vec4 texCoord;
-
- void main(void)
- {
- gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
- texCoord = qt_MultiTexCoord0;
- }
- \endcode
-
- \section1 Standard uniform variables
-
- ShaderProgram provides a standard set of uniform variables for
- common values from the environment:
-
- \table
- \header \o Shader Variable \o Purpose
- \row \o \c qt_ModelViewProjectionMatrix
- \o Combination of the modelview and projection matrices into a
- single 4x4 matrix.
- \row \o \c qt_ModelViewMatrix
- \o Modelview matrix without the projection. This is typically
- used for performing calculations in eye co-ordinates.
- \row \o \c qt_ProjectionMatrix
- \o Projection matrix without the modelview.
- \row \o \c qt_NormalMatrix
- \o Normal matrix, which is the transpose of the inverse of the
- top-left 3x3 part of the modelview matrix. This is typically
- used in lighting calcuations to transform \c qt_Normal.
- \row \o \c qt_WorldMatrix
- \o Modelview matrix without the eye position and orientation
- component. See QGLPainter::worldMatrix() for further
- information.
- \row \o \c qt_Texture0
- \o Sampler holding the texture from the Effect::texture property.
- \row \o \c qt_Color
- \o Set to the value of the Effect::color property.
- \endtable
-
- The above variables are usually declared in the shaders as follows
- (where \c highp may be replaced with \c mediump or \c lowp depending
- upon the shader's precision requirements):
-
- \code
- uniform highp mat4 qt_ModelViewProjectionMatrix;
- uniform highp mat4 qt_ModelViewMatrix;
- uniform highp mat3 qt_NormalMatrix;
- uniform sampler2D qt_Texture0;
- uniform highp vec4 qt_Color;
- \endcode
-
- Other lighting and material values, such as the ambient, diffuse,
- and specular colors, can be passed to the shader program using
- custom uniform variables, or the standard variable names described
- in the QGLShaderProgramEffect documentation.
-
- \section1 Custom uniform variables
-
- Many properties defined on the ShaderProgram are automatically exposed as
- uniforms for the fragment and vertex shaders under the same name.
-
- QML and shader types do not match exactly, so the following table shows
- how QML properties should be declared in qml compared to shader programs:
-
- \table
- \header \o QML Property \o Shader Program Variable
-\row \o \code property double myDouble : 1.0 \endcode \o uniform highp float myDouble;
- \row \o \code property real myReal : 1.0 \endcode \o uniform mediump float myReal;
- \row \o \code property bool myBoolean : true \endcode \o uniform bool myBoolean;
- \row \o \code property int myInt : 1 \endcode \o uniform int myInt;
- \row \o \code property variant myPoint : Qt.point(1, 1) \endcode \o uniform mediump vec2 myPoint;
- \row \o \code property variant myPointF : Qt.point(1.0, 1.0) \endcode \o uniform mediump vec2 myPointF;
- \row \o \code property variant mySize : Qt.size(1.0, 1.0) \endcode \o uniform mediump vec2 mySize;
- \row \o \code property color myColor : "#80c342" \endcode \o uniform lowp vec4 myColor;
- \row \o \code property variant myMatrix3x3 :
- [1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0] \endcode \o uniform mat3 myMatrix3x3;
- \row \o \code property variant myMatrix4x4 :
- [1.0 , 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0 ]\endcode \o uniform mat4 myMatrix4x4;
- \row \o \code property string imageExample :
- "http://example.com/image.png" \endcode \o uniform sampler2D imageExample;
- \endtable
-
- Note: The precision hints in this table are just examples. highp,
- mediump, and lowp do not map directly onto floats, doubles, colors etc.
- Choose the most appropriate variable type for your qml or javascript, and
- the most appropriate precision for your shader program.
-
- Be aware that variant properties in general and matrices in particular
- can have significant performance implications. Conversion from variants
- can be slow, and matrices can consume multiple slots for uniforms, which
- are usually limited by hardware.
-
- String properties are assumed to be urls to images for use in textures.
- Where these images are remote, they are loaded in the background and bound
- to the effect when they are ready.
- \sa QGLGraphicsViewportItem
-*/
-
-class ShaderProgramEffect;
-QT_BEGIN_NAMESPACE
-
-class ShaderProgramPrivate
-{
-public:
- ShaderProgramPrivate()
- : regenerate(false)
- , shadersSupported(true) // Assume supported until known otherwise.
- , effect(0)
- {
- }
-
- QString vertexShader;
- QString fragmentShader;
- QUrl vertexShaderSource;
- QUrl fragmentShaderSource;
- bool regenerate;
- bool shadersSupported;
- ShaderProgramEffect *effect;
-};
-
-
-/*
- \internal
- Construction for the ShaderProgramEffect class consists of setting the key parameter values of the
- class to undefined. As such, a shader program effect with no further initialisation will do nothing at all
- until further creation of shader programs for it has been carried out.
-*/
-ShaderProgramEffect::ShaderProgramEffect(ShaderProgram* parent)
-{
- this->parent = parent;
- nextTextureUnit = 1;
- propertyListener = new ShaderProgramPropertyListenerEx(parent, this);
-}
-
-/*
- \internal
- Destruction entails deletion of the underlying \l QGLShaderProgram which forms the functional core of the
- class.
-*/
-ShaderProgramEffect::~ShaderProgramEffect()
-{
- QList<QGLTexture2D*> textures = texture2Ds.values();
- QGLTexture2D* texture;
- foreach (texture, textures)
- delete texture;
-}
-
-/*
- \internal
- The act of shader programe creation can be undertakn in the manner defined for the QGLShaderProgram class.
- Failure to successfully carry out creation will result in a warning message. Success will auto-populate the
- parameter fields of the ShaderProgramEffect with the necessary values based on the shader program.
-
- The vertex shader source is defined as a QString in the \a vertexShader parameter, while the fragment shader
- is provided in the \a fragmentShader parameter.
-*/
-bool ShaderProgramEffect::create
- (const QString& vertexShader, const QString& fragmentShader)
-{
- if (!QGLShaderProgram::hasOpenGLShaderPrograms())
- return false;
-
- setVertexShader(vertexShader.toLatin1());
- setFragmentShader(fragmentShader.toLatin1());
-
- return true;
-}
-
-/*!
- \internal
- Convenience function to setup the relationship between object properties
- and shader uniforms for later use.
- */
-void ShaderProgramEffect::afterLink()
-{
- propertyIdsToUniformLocations.clear();
- uniformLocationsToTextureUnits.clear();
- nextTextureUnit = 1;
- propertyListener->disconnect();
- if (parent.data() == 0)
- {
- return;
- }
- QObject::connect(propertyListener, SIGNAL(propertyChanged()), parent.data(), SIGNAL(effectChanged()));
-
- const QMetaObject* parentMetaObject = parent.data()->metaObject();
- int parentMethodCount = parentMetaObject->methodCount();
-
- for (int i = parentMetaObject->propertyOffset();
- i < parentMetaObject->propertyCount(); i++)
- {
- QMetaProperty metaProperty = parentMetaObject->property(i);
- QByteArray propertyName = metaProperty.name();
- int location = program()->uniformLocation(propertyName);
- // -1 indicates that the program does not use the variable,
- // so ignore those variables.
- if (location != -1)
- {
- dirtyProperties.append(i);
- propertyIdsToUniformLocations[i] = location;
- if (metaProperty.hasNotifySignal())
- {
- QMetaMethod notifySignal = metaProperty.notifySignal();
-
- int signalIndex = notifySignal.methodIndex();
-
- // Connect the myFooChanged() signal from the ShaderProgram
- // to the corresponding imaginary slot on the listener
- // Use the method count to make sure that we don't stomp on
- // real methods and add the property index to tell the
- // properties apart.
- // Warning: Subclasses of ShaderProgramPropertyListener will
- // generate spurious property updates and lots of warnings
- // and might even crash
- QMetaObject::connect(parent.data(), signalIndex,
- propertyListener, parentMethodCount + i);
- } else {
- qWarning() << "Warning: No notification signal found for property: " << propertyName;
- propertiesWithoutNotificationSignal.append(i);
- }
- }
- }
-
- // Refresh everything
- this->setPropertiesDirty();
-}
-
-/*!
- \internal
- Precondition: list is a list of floats
- */
-static inline void setUniformFromFloatList(QGLShaderProgram *program, int uniformLocation, QList<QVariant> list)
-{
- switch(list.length())
- {
- case 1:
- program->setUniformValue(uniformLocation, list.at(0).toFloat());
- break;
- case 2:
- program->setUniformValue(uniformLocation,
- list.at(0).toFloat(),
- list.at(1).toFloat());
- break;
- case 3:
- program->setUniformValue(uniformLocation,
- list.at(0).toFloat(),
- list.at(1).toFloat(),
- list.at(2).toFloat());
- break;
- case 4:
- program->setUniformValue(uniformLocation,
- list.at(0).toFloat(),
- list.at(1).toFloat(),
- list.at(2).toFloat(),
- list.at(3).toFloat());
- break;
- case 9:
- {
- QMatrix3x3 matrix;
- for (int i = 0; i < 9; i++)
- {
- matrix(i / 3, i % 3) = list.at(i).toFloat();
- }
- program->setUniformValue(uniformLocation, matrix);
- }
- break;
- case 16:
- {
- QMatrix4x4 matrix;
- for (int i = 0; i < 16; i++)
- {
- matrix( i / 4, i % 4) = list.at(i).toFloat();
- }
- program->setUniformValue(uniformLocation, matrix);
- }
- break;
- default:
- // Very little information available to make this warning any more helpful
- qWarning() << "Warning: unexpected list size: " << list.size() << ", only 1-4, 9 and 16 supported";
- }
-}
-
-/*!
- \internal
- This performs all updates for the shader program given a QGLPainter \a painter, and the type of update
- being carried out based on the \a updates field, which is an enumeration of the possible painter updates.
-*/
-void ShaderProgramEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
- if (changedTextures.count() > 0)
- {
- foreach (int i, changedTextures)
- {
- if (!images.contains(i))
- {
- changedTextures.remove(i);
- continue;
- }
-
- if (!images[i].isNull())
- {
- setUniform(i, images[i], painter);
- } else
- {
- qWarning() << "Warning: ShaderProgramEffect failed to apply texture for uniform" << i << (urls.contains(i) ? QLatin1String(" url: ") + urls[i] : QString());
- }
- changedTextures.remove(i);
- }
- }
-
- // Update the standard uniform variables.
- QGLShaderProgramEffect::update(painter, updates);
-
- // Assign custom properties if they exist
- if (!parent.data() || !(propertyIdsToUniformLocations.count() > 0))
- return;
-
- // update dirty properties and remove them from the list
- int propertyIndex;
- QList<int> propertiesNotUpdated;
- foreach (propertyIndex, dirtyProperties)
- {
- if (!setUniformForPropertyIndex(propertyIndex, painter))
- {
- propertiesNotUpdated.append(propertyIndex);
- };
- }
- dirtyProperties.clear();
- dirtyProperties.append(propertiesNotUpdated);
-
- // always update the properties we can't track
- foreach (propertyIndex, propertiesWithoutNotificationSignal)
- {
- setUniformForPropertyIndex(propertyIndex, painter);
- }
-}
-
-inline QGLTexture2D* ShaderProgramEffect::textureForUniformValue(int uniformLocation)
-{
- QGLTexture2D* result = texture2Ds.value(uniformLocation);
- if (result == 0)
- {
- result = new QGLTexture2D();
- texture2Ds[uniformLocation] = result;
- }
- return result;
-}
-
-inline bool ShaderProgramEffect::setUniformForPropertyIndex(int propertyIndex, QGLPainter *painter)
-{
- QGLShaderProgram *program = this->program();
- int uniformLocation = propertyIdsToUniformLocations[propertyIndex];
-
- QVariant value =
- parent.data()->metaObject()->property(propertyIndex).read(parent.data());
-
- switch(value.type())
- {
- case QVariant::Double:
- // Convert double to float to pass to shader program
- case QMetaType::Float:
- program->setUniformValue(uniformLocation, value.toFloat());
- break;
- case QVariant::Int:
- program->setUniformValue(uniformLocation, value.toInt());
- break;
- case QVariant::UInt:
- program->setUniformValue(uniformLocation, value.toUInt());
- break;
- case QVariant::Bool:
- program->setUniformValue(uniformLocation, value.toBool());
- break;
- case QVariant::Color:
- program->setUniformValue(uniformLocation, value.value<QColor>());
- break;
- case QVariant::List:
- setUniformFromFloatList(program, uniformLocation, value.toList());
- break;
- case QVariant::Point:
- program->setUniformValue(uniformLocation, value.toPoint());
- break;
- case QVariant::PointF:
- program->setUniformValue(uniformLocation, value.toPointF());
- break;
- case QVariant::Size:
- program->setUniformValue(uniformLocation, value.toSize());
- break;
- case QVariant::SizeF:
- program->setUniformValue(uniformLocation, value.toSizeF());
- break;
- case QVariant::Matrix4x4:
- program->setUniformValue(uniformLocation, value.value<QMatrix4x4>());
- break;
- case QVariant::Vector2D:
- program->setUniformValue(uniformLocation, value.value<QVector2D>());
- break;
- case QVariant::Vector3D:
- program->setUniformValue(uniformLocation, value.value<QVector3D>());
- break;
- case QVariant::Vector4D:
- program->setUniformValue(uniformLocation, value.value<QVector4D>());
- break;
- case QVariant::String:
- {
- // We assume strings are URLs to images for textures
- QString urlString = value.toString();
- processTextureUrl(uniformLocation, urlString);
- }
- break;
- case QVariant::Image:
- {
- QImage image(value.toString());
- setUniform(uniformLocation, image, painter);
- }
- break;
- default:
- qWarning() << "Unrecognized variant for property " << parent.data()->metaObject()->property(propertyIndex).name() << " of type " << value.typeName() << ", could not set corresponding shader variable";
- }
- return true;
-}
-
-/*!
- \internal Helper function for applying a \a pixmap to a texture for a shader program. This function should be called from within update() in order to have access to the right GL context through the \a painter.
- */
-void ShaderProgramEffect::setUniform
- (int uniformLocation, const QPixmap pixmap, QGLPainter* painter)
-{
- // TODO: Perspective correction
- QGLTexture2D* texture = textureForUniformValue(uniformLocation);
- int unit = textureUnitForUniformValue(uniformLocation);
- if (texture != 0)
- {
- texture->setPixmap(pixmap);
- painter->glActiveTexture(GL_TEXTURE0 + unit);
- texture->bind();
- program()->setUniformValue(uniformLocation, unit);
- }
-}
-
-/*!
- \internal Helper function for applying an \a images to a texture for a shader program. This function should be called from within update() in order to have access to the right GL context through the \a painter.
- */
-void ShaderProgramEffect::setUniform
- (int uniformLocation, const QImage& image, QGLPainter* painter)
-{
- // TODO: Perspective correction
- QGLTexture2D* texture = textureForUniformValue(uniformLocation);
- int unit = textureUnitForUniformValue(uniformLocation);
- if (texture != 0)
- {
- texture->setImage(image);
- painter->glActiveTexture(GL_TEXTURE0 + unit);
- texture->bind();
- program()->setUniformValue(uniformLocation, unit);
- }
-}
-
-/*!
- \internal Find the texture unit to associate with \a uniformLocation.
-*/
-int ShaderProgramEffect::textureUnitForUniformValue(int uniformLocation)
-{
- int unit = uniformLocationsToTextureUnits.value(uniformLocation, -1);
- if (unit == -1) {
- unit = nextTextureUnit++;
- uniformLocationsToTextureUnits[uniformLocation] = unit;
- }
- return unit;
-}
-
-/*!
- \internal set all properties dirty so they are reuploaded
- next update()
- */
-void ShaderProgramEffect::setPropertiesDirty()
-{
- dirtyProperties = this->propertyIdsToUniformLocations.keys();
-}
-
-/*!
- \internal Set a specific property as dirty so that it is reuploaded
- next update()
- */
-void ShaderProgramEffect::setPropertyDirty(int property)
-{
- if (dirtyProperties.indexOf(property) == -1)
- {
- dirtyProperties.append(property);
- }
-}
-
-/*!
- \internal Update the image for the texture bound at \a uniform location with
- the the image at \a urlString. If \a urlString is a remote resource, this
- starts an asycnrounous loading process.
-
- Note: Consecutive calls with the same url for a given uniform are ignored.
-*/
-void ShaderProgramEffect::processTextureUrl(int uniformLocation, QString urlString)
-{
- QUrl url(urlString);
- if (urlString.isEmpty() &&
- urls.contains(uniformLocation) &&
- !urls[uniformLocation].isNull())
- {
- if (images.contains(uniformLocation) && !images[uniformLocation].isNull())
- {
- images[uniformLocation] = QImage();
- urls.remove(uniformLocation);
- changedTextures.insert(uniformLocation);
- return;
- }
- };
-
- bool async = true;
- // Try to make path absolute:
- if (url.isRelative())
- {
- async = false;
- // Get the baseUrl from the declarative engine
- QDeclarativeContext *context =
- QDeclarativeEngine::contextForObject(parent.data());
-
- if (context)
- {
- QUrl baseurl = context->baseUrl();
- QUrl absolute = baseurl.resolved(urlString);
-
- if (absolute.isValid())
- {
- url = absolute;
- urlString = absolute.toString();
- } else {
- qWarning() << "Warning: failed to resolve relative path " <<
- urlString;
- }
- }
- };
-
- if (urlString != urls[uniformLocation])
- {
- if (url.scheme() != QLatin1String("file"))
- {
- // TODO - support network URL's for loading - note that this feature is for
- // the Qt3D 1.1 release and there is no point in implementing it until for example
- // model loading and all other parts of Qt3D support it. Also when it is implemented
- // it has to be done with a facility that does not depend on private headers in
- // QtDeclarative which can change within minor dot-point releases.
- qWarning("Network URL's not yet supported - %s", qPrintable(urlString));
- }
- else
- {
- QString localFile = url.toLocalFile();
- if (localFile.endsWith(QLatin1String(".dds")))
- {
- qWarning("Shader effects with compressed textures not supported: %s",
- qPrintable(urlString));
- }
- else
- {
- QImage im(localFile);
- if (im.isNull())
- {
- qWarning("Could not load image from local file path - %s", qPrintable(localFile));
- }
- else
- {
- images[uniformLocation] = im;
- changedTextures.insert(uniformLocation);
- }
- }
- }
- }
-}
-
-/*!
- \internal
- Construction of the shader program and assignment of its \a parent object.
-*/
-ShaderProgram::ShaderProgram(QObject *parent)
- : QDeclarativeEffect(parent)
-{
- d = new ShaderProgramPrivate();
-}
-
-/*!
- \internal
- Destruction of the ShaderProgram entails deletion of private data, and explicit deletion of the
- underlying ShaderProgramEffect defined by the class.
-*/
-ShaderProgram::~ShaderProgram()
-{
- delete d->effect;
- delete d;
-}
-
-/*!
- \qmlproperty string ShaderProgram::vertexShader
-
- This property defines the source for the vertex shader to be implemented by this
- instance of the ShaderProgram. This property and the vertexShaderSource()
- property both effect the same underlying object, so setting one will override
- the other.
-
- \sa fragmentShader, vertexShaderSource
-*/
-QString ShaderProgram::vertexShader() const
-{
- return d->vertexShader;
-}
-
-void ShaderProgram::setVertexShader(const QString& value)
-{
- if (!d->vertexShaderSource.isEmpty() || value != d->vertexShader)
- {
- d->vertexShader = value;
- d->regenerate = true;
- d->vertexShaderSource = QUrl();
- emit shaderChanged();
- emit effectChanged();
- }
-}
-
-/*!
- \qmlproperty string ShaderProgram::fragmentShader
- This property defines the source for the fragment shader (ie. pixel shader) to be
- implemented by this instance of the ShaderProgram. This property and the
- fragmentShaderSource() property both effect the same underlying object, so
- setting one will override the other.
-
- \sa vertexShader, fragmentShaderSource
-*/
-QString ShaderProgram::fragmentShader() const
-{
- return d->fragmentShader;
-}
-
-void ShaderProgram::setFragmentShader(const QString& value)
-{
- if (!d->fragmentShaderSource.isEmpty() || value != d->fragmentShader)
- {
- d->fragmentShader = value;
- d->regenerate = true;
- d->fragmentShaderSource = QUrl();
- emit shaderChanged();
- emit effectChanged();
- }
-}
-
-/*!
- \qmlproperty QUrl ShaderProgram::vertexShaderSource
- This property allows the source for the vertex shader to be set to the contents
- of a file containing shader source code. This property and the vertexShader()
- property both effect the same underlying object, so setting one will override
- the other.
-
- Note that at present networked URLs are not supported, only local files. If a
- URL has not been set for the vertex shader, for example because it was
- specified via the vertexShader() in-line shader code property, then this property
- will return a null (empty) QUrl.
-
- \sa vertexShader, fragmentShaderSource
-*/
-QUrl ShaderProgram::vertexShaderSource() const
-{
- return d->vertexShaderSource;
-}
-
-void ShaderProgram::setVertexShaderSource(const QUrl &url)
-{
- if (!url.isEmpty() && url.isValid() && url != d->vertexShaderSource)
- {
- if (url.scheme() == QLatin1String("file"))
- {
- QString fn = url.toLocalFile();
- QFile vs(fn);
- if (vs.open(QIODevice::ReadOnly))
- {
- d->vertexShader = vs.readAll();
- d->vertexShaderSource = url;
- emit shaderChanged();
- emit effectChanged();
- d->regenerate = true;
- }
- else
- {
- qWarning() << "Unable to read" << url;
- }
- }
- else
- {
- qWarning() << "vertexShaderSource property does not (yet) support non-file URLs";
- }
- }
-}
-
-/*!
- \qmlproperty QUrl ShaderProgram::fragmentShaderSource
- This property allows the source for the fragment shader to be set to the contents
- of a file containing shader source code. This property and the vertexShader()
- property both effect the same underlying object, so setting one will override
- the other.
-
- Note that at present networked URLs are not supported, only local files. If a
- URL has not been set for the fragment shader, for example because it was
- specified via the fragmentShader() in-line shader code property, then this property
- will return a null (empty) QUrl.
-
- \sa fragmentShader, vertexShaderSource
-*/
-QUrl ShaderProgram::fragmentShaderSource() const
-{
- return d->fragmentShaderSource;
-}
-
-void ShaderProgram::setFragmentShaderSource(const QUrl &url)
-{
- if (!url.isEmpty() && url.isValid() && url != d->fragmentShaderSource)
- {
- if (url.scheme() == QLatin1String("file"))
- {
- QString fn = url.toLocalFile();
- QFile fs(fn);
- if (fs.open(QIODevice::ReadOnly))
- {
- d->fragmentShader = fs.readAll();
- d->fragmentShaderSource = url;
- emit shaderChanged();
- emit effectChanged();
- d->regenerate = true;
- }
- else
- {
- qWarning() << "Unable to read fragment shader" << url;
- }
- }
- else
- {
- qWarning() << "fragmentShaderSource property does not (yet) support non-file URLs";
- }
- }
-}
-
-/*!
- \internal
- Enables the effect for a given \a painter. If the effect has not been created yet, this function will
- attempt to do so.
-*/
-void ShaderProgram::enableEffect(QGLPainter *painter)
-{
- if (!d->shadersSupported && !d->regenerate) {
- // Use a simple fallback effect.
- QDeclarativeEffect::enableEffect(painter);
- return;
- }
- if (!d->effect) {
- // note that the ShaderProgramEffect can also be created when this
- // effect is applied to a QGLSceneNode if that happens first
- d->effect = new ShaderProgramEffect(this);
- if (!d->effect->create(d->vertexShader, d->fragmentShader)) {
- delete d->effect;
- d->effect = 0;
- QDeclarativeEffect::enableEffect(painter);
- d->regenerate = false;
- d->shadersSupported = false;
- return;
- }
- d->shadersSupported = true;
- } else if (d->regenerate) {
- if (!d->effect->create(d->vertexShader, d->fragmentShader)) {
- delete d->effect;
- d->effect = 0;
- QDeclarativeEffect::enableEffect(painter);
- d->regenerate = false;
- d->shadersSupported = false;
- return;
- }
- d->shadersSupported = true;
- }
- d->regenerate = false;
- painter->setUserEffect(d->effect);
- painter->setColor(color());
- QGLTexture2D *tex = texture2D();
- painter->glActiveTexture(GL_TEXTURE0);
- if (tex)
- tex->bind();
- else
- glBindTexture(GL_TEXTURE_2D, 0);
-}
-
-/*!
- \internal
- Set a scenenode's material and effect properties to enact this effect.
-
- This can happen before glInitialize, so setup is delayed until the effect is
- used or explicitly initialized.
-*/
-void ShaderProgram::applyTo(QGLSceneNode *node)
-{
- if (!d->effect) {
- // This function is often called during setup, before glInitilization,
- // so create the effect now, and then initializion it later.
- d->effect = new ShaderProgramEffect(this);
- d->regenerate = true;
- }
- node->setUserEffect(d->effect);
-}
-
-/*!
- \internal
- Mark all properties as dirty to be re-uploaded in the next update
-*/
-void ShaderProgram::markAllPropertiesDirty()
-{
- d->effect->setPropertiesDirty();
-}
-
-/*!
- \internal
- Mark a \a property as dirty to be re-uploaded in the next update
- */
-void ShaderProgram::markPropertyDirty(int property)
-{
- d->effect->setPropertyDirty(property);
-}
-
-/*!
- \qmlsignal ShaderProgram::onFinishedLoading()
- Emitted when the last remote resource request is resolved, and implies that
- the effect is ready to be displayed.
-*/
-
-/*!
- \internal
- A subclass without the Q_OBJECT macro in order to use the qt_metacall trick to track property changes.
-
- It is also conveniently placed to connect appropriate properties to
- Effect::effectChanged() to trigger timely updates.
- */
-ShaderProgramPropertyListenerEx::ShaderProgramPropertyListenerEx(ShaderProgram *parent, ShaderProgramEffect* effect)
- : ShaderProgramPropertyListener(parent), effect(effect)
-{
- shaderProgramMethodCount = parent->metaObject()->methodCount();
-}
-
-/*!
- \internal
-*/
-ShaderProgramPropertyListenerEx::~ShaderProgramPropertyListenerEx()
-{
-}
-
-/*!
- \internal
- Find calls to the "imaginary" slots, and mark the appropriate property
- as dirty.
-*/
-int ShaderProgramPropertyListenerEx::qt_metacall(QMetaObject::Call c, int id, void **a)
-{
- if (c == QMetaObject::InvokeMetaMethod )
- {
- if (id >= shaderProgramMethodCount) {
- effect->setPropertyDirty(id - shaderProgramMethodCount);
- emit propertyChanged();
- }
- // Consume the metacall
- return -1;
- }
-
- return ShaderProgramPropertyListener::qt_metacall(c, id, a);
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/threed/shaderprogram.h b/src/imports/threed/shaderprogram.h
deleted file mode 100644
index d1986614..00000000
--- a/src/imports/threed/shaderprogram.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SHADERPROGRAM_H
-#define SHADERPROGRAM_H
-
-#include "qdeclarativeeffect.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class ShaderProgramPrivate;
-class QGLSceneNode;
-
-class ShaderProgram : public QDeclarativeEffect
-{
- Q_OBJECT
- Q_PROPERTY(QString vertexShader READ vertexShader WRITE setVertexShader NOTIFY shaderChanged)
- Q_PROPERTY(QString fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY shaderChanged)
- Q_PROPERTY(QUrl vertexShaderSource READ vertexShaderSource WRITE setVertexShaderSource NOTIFY shaderChanged)
- Q_PROPERTY(QUrl fragmentShaderSource READ fragmentShaderSource WRITE setFragmentShaderSource NOTIFY shaderChanged)
-public:
- ShaderProgram(QObject *parent = 0);
- virtual ~ShaderProgram();
-
- QString vertexShader() const;
- void setVertexShader(const QString& value);
-
- QString fragmentShader() const;
- void setFragmentShader(const QString& value);
-
- QUrl vertexShaderSource() const;
- void setVertexShaderSource(const QUrl &url);
-
- QUrl fragmentShaderSource() const;
- void setFragmentShaderSource(const QUrl &url);
-
- virtual void enableEffect(QGLPainter *painter);
- virtual void applyTo(QGLSceneNode *node);
-public Q_SLOTS:
- void markAllPropertiesDirty();
- void markPropertyDirty(int property);
-Q_SIGNALS:
- void finishedLoading();
- void shaderChanged();
-private:
- ShaderProgramPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(ShaderProgram)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/imports/threed/shaderprogram_p.h b/src/imports/threed/shaderprogram_p.h
deleted file mode 100644
index 6b67c4ce..00000000
--- a/src/imports/threed/shaderprogram_p.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SHADERPROGRAM_P_H
-#define SHADERPROGRAM_P_H
-
-#include <QtCore/qsharedpointer.h>
-#include <QtOpenGL/qglshaderprogram.h>
-
-#include "qdeclarativeeffect.h"
-#include "qglshaderprogrameffect.h"
-
-QT_BEGIN_NAMESPACE
-
-class ShaderProgram;
-class ShaderProgramEffect;
-
-/*!
- \internal
- This class's purpose is to be a proxy for signals for the main shader
- program.
-
- This is necessary so the qt_metacall trick can be used to tell apart
- the update signals from QML generated properties. (In short, each update
- signal is connected to an imaginary slot, but calling the slot is
- intercepted and replaced by a call to the appropriate update function).
-*/
-class ShaderProgramPropertyListener : public QObject
-{
- Q_OBJECT
-public:
- ShaderProgramPropertyListener(QObject* parent = 0)
- : QObject(parent)
- {
- }
- virtual ~ShaderProgramPropertyListener()
- {
- }
-Q_SIGNALS:
- void propertyChanged();
-};
-
-/*!
- \internal
- \sa ShaderProgramPropertyListener
-*/
-class ShaderProgramPropertyListenerEx : public ShaderProgramPropertyListener
-{
-public:
- ShaderProgramPropertyListenerEx(ShaderProgram* parent, ShaderProgramEffect* effect);
- ~ShaderProgramPropertyListenerEx();
-
-protected:
- virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
- ShaderProgramEffect* effect;
-private:
- int shaderProgramMethodCount;
-};
-
-
-/*!
- \internal
- The ShaderProgramEffect class underlies the ShaderProgram class in Qml/3d.
- It contains the actual QGLShaderProgram along with all of the necessary
- parameters to use that program.
-*/
-class ShaderProgramEffect : public QGLShaderProgramEffect
-{
-public:
- ShaderProgramEffect(ShaderProgram* parent);
- virtual ~ShaderProgramEffect();
-
- bool create(const QString& vertexShader, const QString& fragmentShader);
-
- void update(QGLPainter *painter, QGLPainter::Updates updates);
- bool setUniformForPropertyIndex(int propertyIndex, QGLPainter *painter);
-
- void setPropertiesDirty();
- void setPropertyDirty(int property);
-
- void setAttributeFields(QGL::VertexAttribute fields);
-protected:
- void processTextureUrl(int uniformLocation, QString urlString);
- void afterLink();
-
-private:
- void setUniform(int uniformValue, const QImage& image,
- QGLPainter* painter);
- void setUniform(int uniformValue, const QPixmap pixmap,
- QGLPainter* painter);
- QGLTexture2D* textureForUniformValue(int uniformLocation);
- int textureUnitForUniformValue(int uniformLocation);
-
- QWeakPointer<ShaderProgram> parent;
- int nextTextureUnit;
- QMap<int, int> propertyIdsToUniformLocations;
- QMap<int, int> uniformLocationsToTextureUnits;
- QList<int> dirtyProperties;
- QArray<int> propertiesWithoutNotificationSignal;
- ShaderProgramPropertyListener* propertyListener;
-
- // Thes maps are all referenced by uniform location
- QMap<int, QGLTexture2D*> texture2Ds;
- QMap<int, QImage> images;
- QMap<int, QString> urls;
-
- // These are sets of uniform locations
- QSet<int> loadingTextures;
- QSet<int> changedTextures;
-};
-
-QT_END_NAMESPACE
-
-#endif // SHADERPROGRAM_P_H
diff --git a/src/imports/threed/skybox.cpp b/src/imports/threed/skybox.cpp
deleted file mode 100644
index aa0edbbc..00000000
--- a/src/imports/threed/skybox.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "skybox.h"
-#include "qglbuilder.h"
-#include "qglcube.h"
-#include "qglpainter.h"
-#include "qglview.h"
-#include "viewport.h"
-
-#include <QDir>
-#include <QFileInfo>
-#include <QEvent>
-
-/*!
- \qmlclass Skybox Skybox
- \brief The Skybox item provides a simple 6-texture environment.
- \since 4.8
- \ingroup qt3d::qml3d
-
- The six textures of the Skybox completely encloses the camera,
- giving the illusion of a full 3D environment. Although the illusion
- is far from perfect it is adequate for many simple purposes. It is
- most suited to sky, clouds, remote landscapes (such as mountains) or
- possibly city skylines - anything where the textures represent an
- environment that is effectively infinitely distant from the camera.
-
- To use a skybox create a directory with six appropriately named images
- and place this alongside the main qml file, then specify the directory
- name for the \l{source} property:
-
- \code
- Viewport {
-
- Skybox {
- source: "skybox"
- }
-
- Cube { }
- }
- \endcode
-
- For an illustration of its use see the flickr3d example.
-*/
-const char * Skybox::EXPECTED_NAMES[] = {
- "_west", "_up", "_east", "_down", "_south", "_north", 0 };
-
-Skybox::Skybox(QObject *parent)
- : m_ready(false)
- , m_scene(0)
- , m_view(0)
- , m_camera(new QGLCamera(this))
-{
- m_view = qobject_cast<Viewport*>(parent);
-
- //Set the eye to to 0,0,0 and the near plane/view size such that
- //a wide variety of aspect ratios will display without undue
- //cropping against the near plane.
- m_camera->setEye(QVector3D());
- m_camera->setNearPlane(0.1f);
- m_camera->setViewSize(QSizeF(0.17f, 0.17f));
-
- QGLBuilder builder;
- builder.newSection(QGL::Faceted);
- QVector3D blb(-1.0, -1.0, -1.0);
- QVector3D blf(-1.0, -1.0, 1.0);
- QVector3D tlf(-1.0, 1.0, 1.0);
- QVector3D tlb(-1.0, 1.0, -1.0);
- QVector3D brb(1.0, -1.0, -1.0);
- QVector3D brf(1.0, -1.0, 1.0);
- QVector3D trf(1.0, 1.0, 1.0);
- QVector3D trb(1.0, 1.0, -1.0);
- QVector2D bl(0.0f, 0.0f);
- QVector2D br(1.0f, 0.0f);
- QVector2D tr(1.0f, 1.0f);
- QVector2D tl(0.0f, 1.0f);
- {
- QGeometryData q; // left
- builder.currentNode()->setObjectName("left");
- q.appendVertex(blf, blb, tlb, tlf);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[0] = builder.currentNode();
- m_faces[0]->setMaterial(new QGLMaterial);
- }
- {
- builder.newNode(); // top
- builder.currentNode()->setObjectName("top");
- QGeometryData q;
- q.appendVertex(trf, tlf, tlb, trb);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[1] = builder.currentNode();
- m_faces[1]->setMaterial(new QGLMaterial);
- }
- {
- builder.newNode(); // right
- builder.currentNode()->setObjectName("right");
- QGeometryData q;
- q.appendVertex(brb, brf, trf, trb);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[2] = builder.currentNode();
- m_faces[2]->setMaterial(new QGLMaterial);
- }
- {
- builder.newNode(); // bottom
- builder.currentNode()->setObjectName("bottom");
- QGeometryData q;
- q.appendVertex(brb, blb, blf, brf);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[3] = builder.currentNode();
- m_faces[3]->setMaterial(new QGLMaterial);
- }
- {
- builder.newNode(); // front
- builder.currentNode()->setObjectName("front");
- QGeometryData q;
- q.appendVertex(brf, blf, tlf, trf);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[4] = builder.currentNode();
- m_faces[4]->setMaterial(new QGLMaterial);
- }
- {
- builder.newNode(); // back
- builder.currentNode()->setObjectName("back");
- QGeometryData q;
- q.appendVertex(blb, brb, trb, tlb);
- q.appendTexCoord(bl, br, tr, tl);
- builder.addQuads(q);
- m_faces[5] = builder.currentNode();
- m_faces[5]->setMaterial(new QGLMaterial);
- }
- m_scene = builder.finalizedSceneNode();
- m_scene->setObjectName("SkyboxList");
- m_scene->setEffect(QGL::FlatReplaceTexture2D);
- m_scene->setEffectEnabled(true);
- m_scene->setParent(this);
-}
-
-/*!
- \internal
- Destroy this skybox returning all resources
-*/
-Skybox::~Skybox()
-{
-
-}
-/*!
- \internal
-
- Implement the event property to catch when the skybox is placed into a
- viewport parent.
-*/
-bool Skybox::event(QEvent *event)
-{
- if (event->type() == QEvent::ParentChange && !m_view)
- {
- setViewport(qobject_cast<Viewport*>(parent()));
- }
- return QObject::event(event);
-}
-
-/*!
- \qmlproperty Viewport Mesh::viewport
-
- This property holds the viewport which this Skybox will be displayed
- inside. The skybox will completely fill the viewport, but since it is
- drawn first, and with depth buffering off, all other content in the
- given viewport will overlay the skybox making it appear infinitely
- distant.
-
- Generally this property should not need to be set as the skybox can be
- simply placed inside the viewport element in which it should display.
-*/
-void Skybox::setViewport(Viewport *view)
-{
- if (m_view != view)
- {
- m_view = view;
- emit viewportChanged();
- }
-}
-
-void Skybox::scanLocalDir(const QString &imagePath)
-{
- m_imagePath = imagePath;
- QStringList notFound;
- const char **exp = EXPECTED_NAMES;
- for ( ; *exp; ++exp)
- notFound << QLatin1String(*exp);
- QFileInfo info(m_imagePath);
- if (info.exists() && info.isDir())
- {
- QDir imDir(imagePath);
- QFileInfoList files = imDir.entryInfoList(QDir::Files);
- QFileInfoList::const_iterator it = files.constBegin();
- for ( ; it != files.constEnd() && notFound.size() > 0; ++it)
- {
- QFileInfo ent = *it;
- QString tok = ent.baseName().toLower();
- for (int ix = 0; EXPECTED_NAMES[ix]; ++ix)
- {
- if (tok.contains(EXPECTED_NAMES[ix]))
- {
- QUrl url;
- url.setScheme("file");
- url.setPath(ent.absoluteFilePath());
- m_faces[ix]->material()->setTextureUrl(url);
- m_faces[ix]->material()->texture()->setHorizontalWrap(QGL::ClampToEdge);
- m_faces[ix]->material()->texture()->setVerticalWrap(QGL::ClampToEdge);
- notFound.removeOne(QLatin1String(EXPECTED_NAMES[ix]));
- break;
- }
- }
- }
- if (notFound.size() > 0)
- {
- qWarning() << imagePath << "did not contain a skybox image for" << notFound;
- }
- }
- else
- {
- qWarning() << imagePath << "was not a directory of skybox images";
- }
-}
-
-/*!
- \qmlproperty url Skybox::source
-
- The location where the 6 textures for the skybox are stored. The textures are
- in any image format that Qt can load, but must have names that contain the following
- strings:
- \list
- \o "_up"
- \o "_down"
- \o "_west"
- \o "_east"
- \o "_north"
- \o "_south"
- \endlist
- These textures are then attached to the appropriate faces of the skybox.
-*/
-void Skybox::setSource(const QUrl &source)
-{
- if (source != m_source)
- {
- m_source = source;
- if (m_source.scheme() == QLatin1String("file"))
- {
- scanLocalDir(m_source.toLocalFile());
- }
- else
- {
- // TODO - handle network case
- qWarning() << "Network support for skybox images not yet implemented";
- }
- emit sourceChanged();
- }
-}
-
-void Skybox::draw(QGLPainter *painter) const
-{
- if (!m_view)
- return;
- painter->modelViewMatrix().push();
- painter->modelViewMatrix().setToIdentity();
-
- QGLCamera *cam = m_view->camera();
- m_camera->setCenter(-cam->eye());
- painter->setCamera(m_camera);
-
- glDisable(GL_DEPTH_TEST);
-
- m_scene->draw(painter);
-
- glEnable(GL_DEPTH_TEST);
-
- painter->setCamera(cam);
- painter->modelViewMatrix().pop();
-}
-
-/*!
- \internal
-*/
-void Skybox::classBegin()
-{
-}
-
-/*!
- \internal
- Checks that all loading and initialisation has been finished, and emits the loaded() signal if
- the component is complete.
-
- \sa loaded()
-*/
-void Skybox::componentComplete()
-{
-}
diff --git a/src/imports/threed/skybox.h b/src/imports/threed/skybox.h
deleted file mode 100644
index b9baef85..00000000
--- a/src/imports/threed/skybox.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 SKYBOX_H
-#define SKYBOX_H
-
-#include <QString>
-#include <QObject>
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeparserstatus.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLSceneNode;
-class QGLPainter;
-class QGLView;
-class QGLCamera;
-class Viewport;
-
-class Skybox : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(Viewport *viewport READ viewport WRITE setViewport NOTIFY viewportChanged)
-public:
- Skybox(QObject *parent = 0);
- ~Skybox();
- QUrl source() const { return m_source; }
- void setSource(const QUrl &url);
- void draw(QGLPainter *painter) const;
- Viewport *viewport() const
- {
- return m_view;
- }
- void setViewport(Viewport *view);
-
- void classBegin();
- void componentComplete();
-
-Q_SIGNALS:
- void sourceChanged();
- void viewportChanged();
-
-protected:
- bool event(QEvent *event);
-
-private:
- void scanLocalDir(const QString &imagePath);
-
- static const char *EXPECTED_NAMES[];
-
- bool m_ready;
- QGLSceneNode *m_scene;
- QString m_imagePath;
- QUrl m_source;
- QGLSceneNode *m_faces[6];
- Viewport *m_view;
- QGLCamera *m_camera;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Skybox)
-
-QT_END_HEADER
-
-#endif // SKYBOX_H
diff --git a/src/imports/threed/threed.cpp b/src/imports/threed/threed.cpp
deleted file mode 100644
index 3effca86..00000000
--- a/src/imports/threed/threed.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarative.h>
-
-#include "qdeclarativeitem3d.h"
-#include "qdeclarativemesh.h"
-#include "viewport.h"
-#include "qdeclarativeeffect.h"
-#include "scale3d.h"
-#include "skybox.h"
-
-#include "qgraphicsrotation3d.h"
-#include "qgraphicstranslation3d.h"
-#include "qgraphicsscale3d.h"
-#include "qgraphicsbillboardtransform.h"
-#include "qglscenenode.h"
-
-#include "qgraphicslookattransform.h"
-#include "shaderprogram.h"
-#include "qt3dnamespace.h"
-
-#include "billboarditem3d.h"
-
-QML_DECLARE_TYPE(QGraphicsTransform3D)
-QML_DECLARE_TYPE(QGraphicsRotation3D)
-QML_DECLARE_TYPE(QGraphicsTranslation3D)
-QML_DECLARE_TYPE(QGraphicsScale3D)
-QML_DECLARE_TYPE(QGraphicsBillboardTransform)
-QML_DECLARE_TYPE(QGraphicsLookAtTransform)
-QML_DECLARE_TYPE(QGLMaterial)
-QML_DECLARE_TYPE(QGLLightModel)
-QML_DECLARE_TYPE(QGLLightParameters)
-QML_DECLARE_TYPE(QGLCamera)
-
-QT_BEGIN_NAMESPACE
-
-class QThreedQmlModule : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- virtual void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt3D"));
- qmlRegisterType<QGLSceneNode>(uri,1,0,"SceneNode");
- qmlRegisterType<QDeclarativeEffect>(uri,1,0,"Effect");
- qmlRegisterType<QDeclarativeMesh>(uri,1,0,"Mesh");
- qmlRegisterType<QDeclarativeItem3D>(uri,1,0,"Item3D");
- qmlRegisterType<QGLLightModel>(uri,1,0,"LightModel");
- qmlRegisterType<QGLLightParameters>(uri,1,0,"Light");
- qmlRegisterType<QGLCamera>(uri,1,0,"Camera");
- qmlRegisterType<QGraphicsRotation3D>(uri,1,0,"Rotation3D");
- qmlRegisterType<QGraphicsTranslation3D>(uri,1,0,"Translation3D");
- qmlRegisterType<Scale3D>(uri,1,0,"Scale3D");
- qmlRegisterType<QGraphicsBillboardTransform>(uri,1,0,"BillboardTransform");
- qmlRegisterType<QGraphicsLookAtTransform>(uri,1,0,"LookAt");
- qmlRegisterType<QGLMaterial>(uri,1,0,"Material");
- qmlRegisterType<ShaderProgram>(uri,1,0,"ShaderProgram");
- qmlRegisterType<Skybox>(uri, 1, 0, "Skybox");
- qmlRegisterType<BillboardItem3D>(uri, 1, 0, "BillboardItem3D");
-
- qmlRegisterType<Viewport>(uri,1,0,"Viewport");
-
- // Needed to make QDeclarativeListProperty<QGraphicsTransform3D> work.
- qmlRegisterType<QGraphicsTransform3D>();
- qmlRegisterType<QGraphicsScale3D>();
-
-#ifdef QT_USE_SCENEGRAPH
- qmlRegisterType<ViewportSG>(uri,2,0,"Viewport");
-#endif
- }
- void initializeEngine(QDeclarativeEngine *engine, const char *uri)
- {
- Q_UNUSED(uri);
- QDeclarativeContext *context = engine->rootContext();
- context->setContextProperty(QLatin1String("Qt3D"), new Qt3DNamespace);
- }
-};
-
-QT_END_NAMESPACE
-
-#include "threed.moc"
-
-Q_EXPORT_PLUGIN2(qthreedqmlplugin, QT_PREPEND_NAMESPACE(QThreedQmlModule));
diff --git a/src/imports/threed/threed.pro b/src/imports/threed/threed.pro
deleted file mode 100644
index c674d22e..00000000
--- a/src/imports/threed/threed.pro
+++ /dev/null
@@ -1,74 +0,0 @@
-TEMPLATE = lib
-TARGET = qthreedqmlplugin
-CONFIG += qt plugin
-
-CONFIG += qt3dquick_deploy_pkg
-include(../../../pkg.pri)
-
-# See the README in the root dir re this code
-package {
- target.path += $$QT3D_INSTALL_IMPORTS/Qt3D
- INSTALLS += target
-} else {
- CONFIG += qt3dquick qt3d
- DESTDIR = $$QT3D_INSTALL_IMPORTS/Qt3D
-}
-
-win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- }
-}
-
-symbian {
- CONFIG += epocallowdlldata
- MMP_RULES += EXPORTUNFROZEN
- LIBS += -lQt3D$${QT_LIBINFIX} -lQt3DQuick$${QT_LIBINFIX}
- TARGET.CAPABILITY = All -Tcb
- TARGET.UID3 = 0x20031E9B
-}
-
-SOURCES += \
- threed.cpp \
- qt3dnamespace.cpp \
- scale3d.cpp \
- viewport.cpp \
- qgraphicslookattransform.cpp \
- shaderprogram.cpp \
- skybox.cpp \
- billboarditem3d.cpp
-
-HEADERS += \
- qt3dnamespace.h \
- scale3d.h \
- viewport.h \
- qgraphicslookattransform.h \
- shaderprogram.h \
- shaderprogram_p.h \
- skybox.h \
- billboarditem3d.h
-
-# See the file README.library_xml for more on this
-QML_INFRA_FILES += \
- qmldir \
- library.xml \
- plugins.qmltypes
-
-package {
- copyqmlinfra_install.files = $$QML_INFRA_FILES
- copyqmlinfra_install.path = $$QT3D_INSTALL_IMPORTS/Qt3D
- INSTALLS += copyqmlinfra_install
-} else {
- copyqmlinfra.input = QML_INFRA_FILES
- copyqmlinfra.output = $$[QT_INSTALL_IMPORTS]/Qt3D/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- copyqmlinfra.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- copyqmlinfra.CONFIG += no_link_no_clean
- copyqmlinfra.variable_out = PRE_TARGETDEPS
- QMAKE_EXTRA_COMPILERS += copyqmlinfra
-}
-
-OTHER_FILES += \
- README.plugins_types \
- README.library_xml
-
-
diff --git a/src/imports/threed/viewport.cpp b/src/imports/threed/viewport.cpp
deleted file mode 100644
index 5f4169e3..00000000
--- a/src/imports/threed/viewport.cpp
+++ /dev/null
@@ -1,1289 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "viewport.h"
-#include "qdeclarativeeffect.h"
-
-#include "qgllightmodel.h"
-#include "qgllightparameters.h"
-#include "qglcamera.h"
-#include "qglview.h"
-#include "qglsubsurface.h"
-#include "qray3d.h"
-#include "qglframebufferobjectsurface.h"
-#include "skybox.h"
-
-#include <QtGui/qpainter.h>
-#include <QtGui/qgraphicsview.h>
-#include <QtGui/qgraphicsscene.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QtGui/qevent.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qpointer.h>
-
-/*!
- \qmlclass Viewport Viewport
- \brief The Viewport item defines the logical viewport for a 3D scene. It includes all necessary
- references and parameters for the contents of the scene, as well as drawing and painting functions
- \since 4.8
- \ingroup qt3d::qml3d
-
- The Viewport item is usually the outermost in a 3D scene, specifying
- the size of the view, the camera position, lights, and the main 3D object:
-
- \code
- import QtQuick 1.0
- import Qt3D 1.0
-
- Viewport {
- width: 640; height: 480
- camera: Camera {}
- light: Light {}
- Item3D {
- mesh: Mesh { source: "meshes/teapot.bez" }
- effect: Effect {}
- }
- }
- \endcode
-
- \sa Camera
-*/
-
-QT_BEGIN_NAMESPACE
-
-class ViewportPrivate
-{
-public:
- ViewportPrivate();
- ~ViewportPrivate();
-
- bool picking;
- bool showPicking;
- bool showSceneGraph;
- int dumpCount;
- bool navigation;
- bool fovzoom;
- bool blending;
- bool itemsInitialized;
- bool needsPick;
- QGLCamera *camera;
- QGLLightParameters *light;
- QGLLightModel *lightModel;
- QWidget *viewWidget;
- int pickId;
- QGLFramebufferObject *pickFbo;
- QMap<int, QObject *> objects;
- QPointer<QObject> pressedObject;
- Qt::MouseButton pressedButton;
- QPointer<QObject> enteredObject;
- bool panning;
- QPointF startPan;
- QPointF lastPan;
- QVector3D startEye;
- QVector3D startCenter;
- QVector3D startUpVector;
- Qt::KeyboardModifiers panModifiers;
- QMap<int, QObject*> earlyDrawList;
-
- void setDefaults(QGLPainter *painter);
-};
-
-ViewportPrivate::ViewportPrivate()
- : picking(false)
- , showPicking(false)
- , showSceneGraph(false)
- , dumpCount(10) // maybe this needs to be higher?
- , navigation(true)
- , fovzoom(false)
- , blending(false)
- , itemsInitialized(false)
- , needsPick(true)
- , camera(0)
- , light(0)
- , lightModel(0)
- , viewWidget(0)
- , pickId(1)
- , pickFbo(0)
- , pressedObject(0)
- , pressedButton(Qt::NoButton)
- , enteredObject(0)
- , panning(false)
- , startPan(-1, -1)
- , lastPan(-1, -1)
- , panModifiers(Qt::NoModifier)
-{
-}
-
-ViewportPrivate::~ViewportPrivate()
-{
- delete pickFbo;
-}
-
-void ViewportPrivate::setDefaults(QGLPainter *painter)
-{
- // Set the default depth buffer options.
- glDepthFunc(GL_LESS);
- glDepthMask(GL_TRUE);
-#if defined(QT_OPENGL_ES)
- glDepthRangef(0.0f, 1.0f);
-#else
- glDepthRange(0.0f, 1.0f);
-#endif
-
- // Set the default blend options.
- glDisable(GL_BLEND);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter->glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter->glBlendEquation(GL_FUNC_ADD);
- else if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter->glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
-}
-
-/*!
- \internal
- Construct the class and assign it a \a parent QDeclarativeItem.
-*/
-Viewport::Viewport(QDeclarativeItem *parent)
- : QDeclarativeItem(parent)
-{
- d = new ViewportPrivate();
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-
- connect(this, SIGNAL(viewportChanged()), this, SLOT(update3d()));
-
- setCamera(new QGLCamera(this));
- setLight(new QGLLightParameters(this));
-
- setAcceptedMouseButtons(Qt::LeftButton);
- setAcceptHoverEvents(true);
-}
-
-/*!
- \internal
- Class destruction and cleanup.
-*/
-Viewport::~Viewport()
-{
- delete d;
-}
-
-/*!
- \qmlproperty bool Viewport::picking
-
- User interaction in QML/3d is handled through the concept of object picking. Each
- item has a unique picking id which is queried for a given screen click position when the
- mouse is clicked.
-
- If this property is set to true, picking will be supported for this
- viewport, while if the property is false, no picking will be applied.
-
- The default value for this property is false.
-
- \sa showPicking
-*/
-bool Viewport::picking() const
-{
- return d->picking;
-}
-
-void Viewport::setPicking(bool value)
-{
- d->picking = value;
- emit viewportChanged();
-}
-
-/*!
- \qmlproperty bool Viewport::showPicking
- The underlying mechanism for picking is based on painting an off-screen buffer with a flat
- coloured image containing all of the objects with a unique color value.
-
- Setting this property to true will display this flat-colour picking
- representation in the viewport, which can be useful for debugging
- problems with object selection.
-
- The default value for this property is false.
-
- \sa picking
-*/
-
-bool Viewport::showPicking() const
-{
- return d->showPicking;
-}
-
-void Viewport::setShowPicking(bool value)
-{
- d->showPicking = value;
- emit viewportChanged();
-}
-
-/*!
- \qmlproperty bool Viewport::showSceneGraph
-
- This property controls whether or not the 3D scenegraph structure is dumped
- to the console when the viewport is first rendered. Studying the output can be very
- useful for optimising the scene, and for detecting issues with rendering, such
- as misplaced textures, materials, geometry and so on.
-
- By default the value is set to false.
-*/
-bool Viewport::showSceneGraph() const
-{
- return d->showSceneGraph;
-}
-
-void Viewport::setShowSceneGraph(bool show)
-{
- if (show != d->showSceneGraph)
- {
- d->showSceneGraph = show;
- emit showSceneGraphChanged();
- }
-}
-
-/*!
- \qmlproperty bool Viewport::navigation
-
- This property is used to set or unset camera navigation in for the viewport.
- Camera navigation allows the user to move the camera position around using the mouse.
-
- By default, camera navigation is set to true.
-*/
-bool Viewport::navigation() const
-{
- return d->navigation;
-}
-
-void Viewport::setNavigation(bool value)
-{
- d->navigation = value;
- emit viewportChanged();
-}
-
-/*!
- \qmlproperty bool Viewport::fovzoom
-
- This property is used to set or unset zooming based on field-of-view (fov). Normally
- zooming is achieved by moving the camera physically closer to the target object. This
- options achieves zooming by narrowing or broadening the fov.
-
- By default, fov zooming is set to false.
-*/
-bool Viewport::fovzoom() const
-{
- return d->fovzoom;
-}
-
-void Viewport::setFovzoom(bool value)
-{
- d->fovzoom = value;
- emit viewportChanged();
-}
-
-
-/*!
- \qmlproperty bool Viewport::blending
-
- The blending property is used to enable or disable GL_BLEND
- on the viewport, for alpha blending of drawn objects.
-
- By default, blending is set to false.
-
- \sa Effect::blending
-*/
-bool Viewport::blending() const
-{
- return d->blending;
-}
-
-void Viewport::setBlending(bool value)
-{
- d->blending = value;
- emit viewportChanged();
-}
-
-/*!
- \qmlproperty Camera Viewport::camera
-
- This property sets the camera parameters which will be used for
- the appropriate viewing transforms in OpenGL. The default is
- a perspective camera with its eye located at (0, 0, 10) looking
- at the center (0, 0, 0), with the y axis as up.
-*/
-QGLCamera *Viewport::camera() const
-{
- return d->camera;
-}
-
-void Viewport::setCamera(QGLCamera *value)
-{
- if (d->camera != value) {
- if (d->camera) {
- disconnect(d->camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- disconnect(d->camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
- }
- d->camera = value;
- if (d->camera) {
- connect(d->camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- connect(d->camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
- }
- cameraChanged();
- }
-}
-
-/*!
- \qmlproperty Light Viewport::light
-
- This property defines the main scene light to use for 3D items
- that are drawn in this viewport.
-
- \sa lightModel
-*/
-
-QGLLightParameters *Viewport::light() const
-{
- return d->light;
-}
-
-void Viewport::setLight(QGLLightParameters *value)
-{
- if (d->light != value) {
- if (d->light) {
- disconnect(d->light, SIGNAL(lightChanged()),
- this, SLOT(update3d()));
- }
- d->light = value;
- if (d->light) {
- connect(d->light, SIGNAL(lightChanged()),
- this, SLOT(update3d()));
- }
- emit viewportChanged();
- }
-}
-
-/*!
- \qmlproperty LightModel Viewport::lightModel
- The user is able to set a lighting model for the 3d environment through the use of the
- lightModel property. By default the light model is undefined.
-
- \sa light
-*/
-QGLLightModel *Viewport::lightModel() const
-{
- return d->lightModel;
-}
-
-void Viewport::setLightModel(QGLLightModel *value)
-{
- if (d->lightModel != value) {
- if (d->lightModel) {
- disconnect(d->lightModel, SIGNAL(lightModelChanged()),
- this, SLOT(update3d()));
- }
- d->lightModel = value;
- if (d->lightModel) {
- connect(d->lightModel, SIGNAL(lightModelChanged()),
- this, SLOT(update3d()));
- }
- emit viewportChanged();
- }
-}
-
-class ViewportSubsurface : public QGLSubsurface
-{
-public:
- ViewportSubsurface(QGLAbstractSurface *surface, const QRect &region,
- qreal adjust)
- : QGLSubsurface(surface, region), m_adjust(adjust) {}
-
- qreal aspectRatio() const;
-
-private:
- qreal m_adjust;
-};
-
-qreal ViewportSubsurface::aspectRatio() const
-{
- return QGLSubsurface::aspectRatio() * m_adjust;
-}
-
-/*!
- \internal
- The main paint function for the Viewport class. It takes a QPainter \a p, which performs the
- painting of objects in the 3d environment.
-
- The paint function is responsible for setting up the viewing transform, as well as other display
- options, before calling the draw function to perform the actual drawing of the scene.
-
- Note, currently \a style and \a widget are unused, but are reserved for later development.
-*/
-void Viewport::paint(QPainter *p, const QStyleOptionGraphicsItem * style, QWidget *widget)
-{
- Q_UNUSED(style);
-
- if (!d->viewWidget)
- d->viewWidget = widget;
- d->needsPick = true;
-
- QGLPainter painter;
- if (!painter.begin(p)) {
- if (widget) {
- // Probably running with a plain QDeclarativeView (e.g. qmlviewer).
- // We need to have switched the surrounding QGraphicsView to use a
- // QGLWidget as its viewport.
- QGraphicsView *view =
- qobject_cast<QGraphicsView *>(widget->parentWidget());
- if (!view) {
- return;
- } else {
- QGLWidget *glw = qobject_cast<QGLWidget *>(view->viewport());
- if (!glw) {
- qWarning("GL graphics system is not active; cannot use 3D items");
- return;
- }
- }
- }
- }
-
- // Initialize the objects in the scene if this is the first paint.
- if (!d->itemsInitialized)
- initializeGL(&painter);
-
- painter.setEye(QGL::NoEye);
- qreal adjust = 1.0f;
-
- // Modify the GL viewport to only cover the extent of this QDeclarativeItem.
- QTransform transform = p->combinedTransform();
- QRect viewport = transform.mapRect(boundingRect()).toRect();
- ViewportSubsurface surface(painter.currentSurface(), viewport, adjust);
- painter.pushSurface(&surface);
-
- // Perform early drawing operations.
- earlyDraw(&painter);
-
- // Set up the camera the way QGLView would if we were using it.
- if (d->camera) {
- painter.setCamera(d->camera);
- } else {
- QGLCamera defCamera;
- painter.setCamera(&defCamera);
- }
-
- // Draw the Item3D children.
- painter.setPicking(d->showPicking);
- draw(&painter);
- painter.setPicking(false);
- painter.popSurface();
-
- // Disable the effect to return control to the GL paint engine.
- painter.disableEffect();
-
- // Try to restore the GL state to something paint-engine compatible.
- glDisable(GL_CULL_FACE);
- d->setDefaults(&painter);
- glDisable(GL_DEPTH_TEST);
-
-}
-
-/*!
- \internal
-*/
-void Viewport::earlyDraw(QGLPainter *painter)
-{
- // If we have a parent, then assume that the parent has painted
- // the background and overpaint over the top of it. If we don't
- // have a parent, then clear to black.
- if (parentItem()) {
- glClear(GL_DEPTH_BUFFER_BIT);
- } else {
- painter->setClearColor(Qt::black);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- }
-
- // Force the effect to be updated. The GL paint engine
- // has left the GL state in an unknown condition.
- painter->disableEffect();
-
-#ifdef GL_RESCALE_NORMAL
- glEnable(GL_RESCALE_NORMAL);
-#endif
-
- // Set the default effect for the scene.
- painter->setStandardEffect(QGL::LitMaterial);
- painter->setFaceColor(QGL::AllFaces, Qt::white);
-}
-
-/*!
- \internal
- The draw function for the viewport sets up all of the lighting parameters for the scene before
- iterating through the top level items in the scene and drawing them using \a painter.
-
- As a matter of course each item will draw its child items, and so on, until the entire image has
- been populated.
-*/
-void Viewport::draw(QGLPainter *painter)
-{
- // Set up the initial depth, blend, and other options.
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glDepthMask(GL_TRUE);
-#if defined(QT_OPENGL_ES)
- glDepthRangef(0.0f, 1.0f);
-#else
- glDepthRange(0.0f, 1.0f);
-#endif
-
- // At present only skyboxes work, with early draw and they are drawn
- // without blending and without a lighting model - just flat texture rendering
- int cnt = d->earlyDrawList.size();
- int order = 0;
- while (cnt)
- {
- QMap<int, QObject *>::const_iterator it = d->earlyDrawList.constFind(order);
- while (it != d->earlyDrawList.constEnd())
- {
- // TODO: make more than just skybox work with early draw
- Skybox *sb = qobject_cast<Skybox *>(*it);
- if (sb)
- sb->draw(painter);
- ++it;
- --cnt;
- }
- ++order;
- }
-
- if (d->blending)
- glEnable(GL_BLEND);
- else
- glDisable(GL_BLEND);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter->glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter->glBlendEquation(GL_FUNC_ADD);
- else if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter->glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
- glDisable(GL_CULL_FACE);
-
- painter->setObjectPickId(-1);
- QObjectList list = QObject::children();
- painter->setMainLight(d->light, QMatrix4x4());
- painter->setLightModel(d->lightModel);
- foreach (QObject *child, list) {
- QDeclarativeItem3D *item = qobject_cast<QDeclarativeItem3D *>(child);
- if (item)
- {
- if (d->showSceneGraph && (d->dumpCount == 0))
- qDumpItem(item);
- item->draw(painter);
- }
- }
- if (d->dumpCount >= 0)
- --d->dumpCount;
-}
-
-/*!
- \internal
- Initialize the GL viewport for the first time on \a painter.
-*/
-
-void Viewport::initializeGL(QGLPainter *painter)
-{
- // Initialize the Item3D objects attached to this scene.
- QObjectList list = QObject::children();
- foreach (QObject *child, list) {
- QDeclarativeItem3D *item = qobject_cast<QDeclarativeItem3D *>(child);
- if (item) {
- setItemViewport(item);
- item->initialize(painter);
- }
- // TODO: make this more generic with some sort of abstract interface
- // so that more than just skybox works with early draw
- Skybox *sb = qobject_cast<Skybox *>(child);
- if (sb)
- {
- sb->setViewport(this);
- registerEarlyDrawObject(sb, 0);
- }
- }
- d->itemsInitialized = true;
-}
-
-/*!
- \internal
- Registers \a obj with this viewport as a pickable object and
- return its pick identifier.
-*/
-int Viewport::registerPickableObject(QObject *obj)
-{
- int id = (d->pickId)++;
- d->objects[id] = obj;
- return id;
-}
-
-void Viewport::registerEarlyDrawObject(QObject *obj, int order)
-{
- d->earlyDrawList.insertMulti(order, obj);
-}
-
-/*!
- \internal
- Returns the registered object that is under the mouse position
- specified by (\a x, \a y). This function may need to regenerate
- the contents of the pick buffer by repainting the scene.
-*/
-QObject *Viewport::objectForPoint(qreal x, qreal y)
-{
- if (!d->viewWidget)
- return 0;
-
- // Check the viewport boundaries in case a mouse move has
- // moved the pointer outside the window.
- QRectF rect = boundingRect();
- if (!rect.contains(QPointF(x, y)))
- return 0;
-
- QPainter qpainter;
- QGLPainter painter;
- QGLWidget *glw = qobject_cast<QGLWidget *>(d->viewWidget);
- bool painterValid = false;
- bool doubleBuffer = false;
- if (glw && painter.begin(glw)) {
- doubleBuffer = glw->doubleBuffer();
- painterValid = true;
- } else if (qpainter.begin(d->viewWidget) && painter.begin(&qpainter)) {
- painterValid = true;
- }
-
- if (!painterValid && !QGLContext::currentContext()) {
- // Won't be able to read or generate a pick buffer, so bail out.
- return 0;
- }
-
- int objectId = -1;
-
- QSize size(qRound(width()), qRound(height()));
- QSize fbosize(QGL::nextPowerOfTwo(size));
- if (!d->needsPick && d->pickFbo && d->pickFbo->size() == fbosize
- && painterValid) {
- // The previous pick fbo contents should still be valid.
- d->pickFbo->bind();
- objectId = painter.pickObject(qRound(x), fbosize.height() - 1 - qRound(y));
- d->pickFbo->release();
- } else {
- // Regenerate the pick fbo contents.
- QGLAbstractSurface *mainSurface = 0;
- QGLAbstractSurface *fboSurface = 0;
- int height;
- if (!doubleBuffer) {
- if (d->pickFbo && d->pickFbo->size() != fbosize) {
- delete d->pickFbo;
- d->pickFbo = 0;
- }
- if (!d->pickFbo) {
- d->pickFbo = new QGLFramebufferObject
- (fbosize, QGLFramebufferObject::CombinedDepthStencil);
- }
- height = fbosize.height();
- fboSurface = new QGLFramebufferObjectSurface(d->pickFbo);
- mainSurface = fboSurface;
- } else if (painterValid) {
- // Use the QGLWidget's back buffer for picking to avoid the
- // need to create a separate fbo in GPU memory.
- mainSurface = painter.currentSurface();
- height = mainSurface->viewportGL().height();
- }
- QGLSubsurface surface(mainSurface, QRect(QPoint(0, 0), size));
- // If our view is a hijacked QWidget, we're going to have failed
- // to find a QGLWidget, but we'll still have a QGLContext and be able
- // to draw the pick buffer into the pickFbo.
- if (painterValid || painter.begin(&surface)) {
- if (painterValid)
- painter.pushSurface(&surface);
- painter.setPicking(true);
- painter.clearPickObjects();
- painter.setClearColor(Qt::black);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- painter.setEye(QGL::NoEye);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glDepthMask(GL_TRUE);
-#if defined(QT_OPENGL_ES)
- glDepthRangef(0.0f, 1.0f);
-#else
- glDepthRange(0.0f, 1.0f);
-#endif
- glDisable(GL_BLEND);
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter.glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter.glBlendEquation(GL_FUNC_ADD);
- else if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
- glDisable(GL_CULL_FACE);
- if (d->camera) {
- painter.setCamera(d->camera);
- } else {
- QGLCamera defCamera;
- painter.setCamera(&defCamera);
- }
- draw(&painter);
- painter.setPicking(false);
- objectId = painter.pickObject(qRound(x), height - 1 - qRound(y));
- painter.popSurface();
- painter.end();
- }
- delete fboSurface;
- }
-
- d->needsPick = doubleBuffer;
- return d->objects.value(objectId, 0);
-}
-
-/*!
- \internal
-*/
-void Viewport::update3d()
-{
- update();
-}
-
-/*!
- \internal
-*/
-void Viewport::cameraChanged()
-{
- update();
-}
-
-static inline void sendEnterEvent(QObject *object)
-{
- QEvent event(QEvent::Enter);
- QCoreApplication::sendEvent(object, &event);
-}
-
-static inline void sendLeaveEvent(QObject *object)
-{
- QEvent event(QEvent::Leave);
- QCoreApplication::sendEvent(object, &event);
-}
-
-/*!
- \internal
-*/
-void Viewport::mousePressEvent(QGraphicsSceneMouseEvent *e)
-{
- QObject *object;
- if (!d->panning && d->picking)
- object = objectForPoint(e->pos());
- else
- object = 0;
- if (d->pressedObject) {
- // Send the press event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonPress,
- (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(d->pressedObject, &event);
- } else if (object) {
- // Record the object that was pressed and forward the event.
- d->pressedObject = object;
- d->enteredObject = 0;
- d->pressedButton = e->button();
-
- // Send a mouse press event for (0, 0).
- QMouseEvent event(QEvent::MouseButtonPress, QPoint(0, 0),
- e->screenPos(), e->button(), e->buttons(),
- e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- } else if (d->navigation && e->button() == Qt::LeftButton) {
- d->panning = true;
- d->lastPan = d->startPan = e->pos();
- d->startEye = d->camera->eye();
- d->startCenter = d->camera->center();
- d->startUpVector = d->camera->upVector();
- d->panModifiers = e->modifiers();
-#ifndef QT_NO_CURSOR
- setCursor(Qt::ClosedHandCursor);
-#endif
- } else {
- QDeclarativeItem::mousePressEvent(e);
- return;
- }
- e->setAccepted(true);
-}
-
-/*!
- \internal
-*/
-void Viewport::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
-{
- if (d->panning && e->button() == Qt::LeftButton) {
- d->panning = false;
-#ifndef QT_NO_CURSOR
- unsetCursor();
-#endif
- }
- if (d->pressedObject) {
- // Notify the previously pressed object about the release.
- QObject *object = objectForPoint(e->pos());
- QObject *pressed = d->pressedObject;
- if (e->button() == d->pressedButton) {
- d->pressedObject = 0;
- d->pressedButton = Qt::NoButton;
- d->enteredObject = object;
-
- // Send the release event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonRelease,
- (pressed == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(pressed, &event);
-
- // Send leave and enter events if necessary.
- if (object != pressed) {
- sendLeaveEvent(pressed);
- if (object)
- sendEnterEvent(object);
- }
- } else {
- // Some other button than the original was released.
- // Forward the event to the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonRelease,
- (pressed == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(pressed, &event);
- }
- e->setAccepted(true);
- } else {
- QDeclarativeItem::mouseReleaseEvent(e);
- }
-}
-
-/*!
- \internal
-*/
-void Viewport::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e)
-{
- if (d->picking) {
- QObject *object = objectForPoint(e->pos());
- if (object) {
- // Simulate a double click event for (0, 0).
- QMouseEvent event
- (QEvent::MouseButtonDblClick, QPoint(0, 0),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- e->setAccepted(true);
- return;
- }
- }
- QDeclarativeItem::mouseDoubleClickEvent(e);
-}
-
-/*!
- \internal
-*/
-void Viewport::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
-{
- if (d->panning) {
- QPointF delta = e->pos() - d->startPan;
- if (e->modifiers() == d->panModifiers) {
- d->camera->setEye(d->startEye);
- d->camera->setCenter(d->startCenter);
- d->camera->setUpVector(d->startUpVector);
- } else {
- d->startPan = d->lastPan;
- delta = e->pos() - d->startPan;
- d->startEye = d->camera->eye();
- d->startCenter = d->camera->center();
- d->startUpVector = d->camera->upVector();
- d->panModifiers = e->modifiers();
- }
- d->lastPan = e->pos();
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(delta.y() * -60);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(delta.x(), delta.y());
- else
- rotate(delta.x(), delta.y());
- } else if (d->picking) {
- QObject *object = objectForPoint(e->pos());
- if (d->pressedObject) {
- // Send the move event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseMove,
- (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(d->pressedObject, &event);
- } else if (object) {
- if (object != d->enteredObject) {
- if (d->enteredObject)
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = object;
- sendEnterEvent(d->enteredObject);
- }
- QMouseEvent event
- (QEvent::MouseMove, QPoint(0, 0),
- e->screenPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- } else if (d->enteredObject) {
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = 0;
- } else {
- QDeclarativeItem::mouseMoveEvent(e);
- return;
- }
- } else {
- QDeclarativeItem::mouseMoveEvent(e);
- return;
- }
- e->setAccepted(true);
-}
-
-/*!
- \internal
-*/
-void Viewport::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
-{
- if (hoverEvent(e))
- e->setAccepted(true);
- else
- QDeclarativeItem::hoverEnterEvent(e);
-}
-
-/*!
- \internal
-*/
-void Viewport::hoverMoveEvent(QGraphicsSceneHoverEvent *e)
-{
- if (hoverEvent(e))
- e->setAccepted(true);
- else
- QDeclarativeItem::hoverMoveEvent(e);
-}
-
-/*!
- \internal
-*/
-void Viewport::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
-{
- if (!d->pressedObject && d->enteredObject) {
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = 0;
- e->setAccepted(true);
- } else {
- QDeclarativeItem::hoverLeaveEvent(e);
- }
-}
-
-/*!
- \internal
-*/
-void Viewport::wheelEvent(QGraphicsSceneWheelEvent *e)
-{
- if (d->navigation) {
- wheel(e->delta());
- e->setAccepted(true);
- } else {
- QDeclarativeItem::wheelEvent(e);
- }
-}
-
-/*!
- \internal
-*/
-void Viewport::keyPressEvent(QKeyEvent *e)
-{
- // Process the "Keys" property on the item first.
- keyPressPreHandler(e);
- if (e->isAccepted())
- return;
-
- qreal sep;
-
- if (!d->navigation) {
- QDeclarativeItem::keyPressEvent(e);
- return;
- }
-
- switch (e->key()) {
-
- case Qt::Key_Left:
- {
- if ((e->modifiers() & Qt::ShiftModifier) != 0) {
- pan(-10, 0);
- } else if ((e->modifiers() & Qt::ControlModifier) != 0) {
- sep = d->camera->eyeSeparation();
- sep -= (sep / 10.0f);
- if (sep < 0.0f)
- sep = 0.0f;
- d->camera->setEyeSeparation(sep);
- } else {
- rotate(-10, 0);
- }
- }
- break;
-
- case Qt::Key_Right:
- {
- if ((e->modifiers() & Qt::ShiftModifier) != 0) {
- pan(10, 0);
- } else if ((e->modifiers() & Qt::ControlModifier) != 0) {
- sep = d->camera->eyeSeparation();
- sep += (sep / 10.0f);
- d->camera->setEyeSeparation(sep);
- } else {
- rotate(10, 0);
- }
- }
- break;
-
- case Qt::Key_Up:
- {
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(120);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(0, -10);
- else
- rotate(0, -10);
- }
- break;
-
- case Qt::Key_Down:
- {
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(-120);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(0, 10);
- else
- rotate(0, 10);
- }
- break;
-
- default:
- QDeclarativeItem::keyPressEvent(e);
- return;
- }
-
- e->setAccepted(true);
-}
-
-/*!
- \internal
-*/
-bool Viewport::hoverEvent(QGraphicsSceneHoverEvent *e)
-{
- if (!d->panning && d->picking) {
- QObject *object = objectForPoint(e->pos());
- if (d->pressedObject) {
- // Send the move event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseMove,
- (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->screenPos(), Qt::NoButton, Qt::NoButton, e->modifiers());
- QCoreApplication::sendEvent(d->pressedObject, &event);
- } else if (object) {
- if (object != d->enteredObject) {
- if (d->enteredObject)
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = object;
- sendEnterEvent(d->enteredObject);
- }
- QMouseEvent event
- (QEvent::MouseMove, QPoint(0, 0),
- e->screenPos(), Qt::NoButton, Qt::NoButton, e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- } else if (d->enteredObject) {
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = 0;
- }
- return true;
- }
- return false;
-}
-
-// Zoom in and out according to the change in wheel delta.
-void Viewport::wheel(qreal delta)
-{
- if (d->fovzoom) {
- //Use field-of view as zoom (much like a traditional camera)
- qreal scale = qAbs(viewDelta(delta, delta).x());
- if (delta < 0)
- scale = -scale;
- if (scale >= 0.0f)
- scale += 1.0f;
- else
- scale = 1.0f / (1.0f - scale);
- qreal fov = d->camera->fieldOfView();
- if (fov != 0.0f)
- d->camera->setFieldOfView(d->camera->fieldOfView() / scale);
- else
- d->camera->setViewSize(d->camera->viewSize() / scale);
- } else {
- // enable this to get wheel navigation that actually zooms by moving the
- // camera back, as opposed to making the angle of view wider.
- QVector3D viewVector= camera()->eye() - camera()->center();
- qreal zoomMag = viewVector.length();
- qreal zoomIncrement = -float(delta) / 100.0f;
- if (!qFuzzyIsNull(zoomIncrement))
- {
- zoomMag += zoomIncrement;
- if (zoomMag < 1.0f)
- zoomMag = 1.0f;
-
- QRay3D viewLine(camera()->center(), viewVector.normalized());
- camera()->setEye(viewLine.point(zoomMag));
- }
- }
-}
-
-// Pan left/right/up/down without rotating about the object.
-void Viewport::pan(qreal deltax, qreal deltay)
-{
- QPointF delta = viewDelta(deltax, deltay);
- QVector3D t = d->camera->translation(delta.x(), -delta.y(), 0.0f);
-
- // Technically panning the eye left should make the object appear to
- // move off to the right, but this looks weird on-screen where the user
- // actually thinks they are picking up the object and dragging it rather
- // than moving the eye. We therefore apply the inverse of the translation
- // to make it "look right".
- d->camera->setEye(d->camera->eye() - t);
- d->camera->setCenter(d->camera->center() - t);
-}
-
-// Rotate about the object being viewed.
-void Viewport::rotate(qreal deltax, qreal deltay)
-{
- QRectF rect = boundingRect();
- int rotation = d->camera->screenRotation();
- if (rotation == 90 || rotation == 270) {
- qSwap(deltax, deltay);
- }
- if (rotation == 90 || rotation == 180) {
- deltax = -deltax;
- }
- if (rotation == 180 || rotation == 270) {
- deltay = -deltay;
- }
- qreal anglex = deltax * 90.0f / rect.width();
- qreal angley = deltay * 90.0f / rect.height();
- QQuaternion q = d->camera->pan(-anglex);
- q *= d->camera->tilt(-angley);
- d->camera->rotateCenter(q);
-}
-
-// Convert deltas in the X and Y directions into percentages of
-// the view width and height.
-QPointF Viewport::viewDelta(qreal deltax, qreal deltay)
-{
- QRectF rect = boundingRect();
- qreal w = rect.width();
- qreal h = rect.height();
- bool scaleToWidth;
- qreal scaleFactor, scaleX, scaleY;
- QSizeF viewSize = d->camera->viewSize();
- if (w >= h) {
- if (viewSize.width() >= viewSize.height())
- scaleToWidth = true;
- else
- scaleToWidth = false;
- } else {
- if (viewSize.width() >= viewSize.height())
- scaleToWidth = false;
- else
- scaleToWidth = true;
- }
- int rotation = d->camera->screenRotation();
- if (rotation == 90 || rotation == 270) {
- scaleToWidth = !scaleToWidth;
- qSwap(deltax, deltay);
- }
- if (rotation == 90 || rotation == 180) {
- deltax = -deltax;
- }
- if (rotation == 180 || rotation == 270) {
- deltay = -deltay;
- }
- if (scaleToWidth) {
- scaleFactor = 2.0f / viewSize.width();
- scaleX = scaleFactor * h / w;
- scaleY = scaleFactor;
- } else {
- scaleFactor = 2.0f / viewSize.height();
- scaleX = scaleFactor;
- scaleY = scaleFactor * w / h;
- }
- return QPointF(deltax * scaleX / w, deltay * scaleY / h);
-}
-
-QVariant Viewport::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
-{
- if (change == QGraphicsItem::ItemChildAddedChange)
- {
- QGraphicsItem *newItem = value.value<QGraphicsItem*>();
- if (QDeclarativeItem3D* item3d =
- qobject_cast<QDeclarativeItem3D*>(newItem))
- {
- setItemViewport(item3d);
- }
- };
- return QGraphicsItem::itemChange(change, value);
-}
-QT_END_NAMESPACE
diff --git a/src/imports/threed/viewport.h b/src/imports/threed/viewport.h
deleted file mode 100644
index c0c9c055..00000000
--- a/src/imports/threed/viewport.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 VIEWPORT_H
-#define VIEWPORT_H
-
-#include <QtDeclarative/qdeclarativeitem.h>
-
-#include "qdeclarativeitem3d.h"
-#include "qdeclarativeviewport.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class ViewportPrivate;
-class QGLCamera;
-class QGLLightModel;
-class QGLLightParameters;
-class QDeclarativeEffect;
-
-class Viewport : public QDeclarativeItem, public QDeclarativeViewport
-{
- Q_OBJECT
- Q_PROPERTY(bool picking READ picking WRITE setPicking NOTIFY viewportChanged)
- Q_PROPERTY(bool showPicking READ showPicking WRITE setShowPicking NOTIFY viewportChanged)
- Q_PROPERTY(bool showSceneGraph READ showSceneGraph WRITE setShowSceneGraph NOTIFY showSceneGraphChanged)
- Q_PROPERTY(bool navigation READ navigation WRITE setNavigation NOTIFY viewportChanged)
- Q_PROPERTY(bool fovzoom READ fovzoom WRITE setFovzoom NOTIFY viewportChanged)
- Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY viewportChanged)
- Q_PROPERTY(QGLCamera *camera READ camera WRITE setCamera)
- Q_PROPERTY(QGLLightParameters *light READ light WRITE setLight NOTIFY viewportChanged)
- Q_PROPERTY(QGLLightModel *lightModel READ lightModel WRITE setLightModel NOTIFY viewportChanged)
-public:
- Viewport(QDeclarativeItem *parent = 0);
- ~Viewport();
-
- bool picking() const;
- void setPicking(bool value);
-
- bool showPicking() const;
- void setShowPicking(bool value);
-
- bool showSceneGraph() const;
- void setShowSceneGraph(bool show);
-
- bool navigation() const;
- void setNavigation(bool value);
-
- bool fovzoom() const;
- void setFovzoom(bool value);
-
- bool blending() const;
- void setBlending(bool value);
-
- QGLCamera *camera() const;
- void setCamera(QGLCamera *value);
-
- QGLLightParameters *light() const;
- void setLight(QGLLightParameters *value);
-
- QGLLightModel *lightModel() const;
- void setLightModel(QGLLightModel *value);
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
- int registerPickableObject(QObject *obj);
- virtual void registerEarlyDrawObject(QObject *obj, int order);
-
- Q_INVOKABLE QObject *objectForPoint(qreal x, qreal y);
-
-Q_SIGNALS:
- void viewportChanged();
- void showSceneGraphChanged();
-
-public Q_SLOTS:
- void update3d();
-
-private Q_SLOTS:
- void cameraChanged();
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
- void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- void wheelEvent(QGraphicsSceneWheelEvent *event);
- void keyPressEvent(QKeyEvent *event);
- virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
-
-private:
- ViewportPrivate *d;
-
- void earlyDraw(QGLPainter *painter);
- void draw(QGLPainter *painter);
- void initializeGL(QGLPainter *painter);
-
- bool hoverEvent(QGraphicsSceneHoverEvent *event);
-
- QObject *objectForPoint(const QPointF &pos)
- {
- return objectForPoint(pos.x(), pos.y());
- }
-
- void wheel(qreal delta);
- void pan(qreal deltax, qreal deltay);
- void rotate(qreal deltax, qreal deltay);
- QPointF viewDelta(qreal deltax, qreal deltay);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Viewport)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
deleted file mode 100644
index 19979051..00000000
--- 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 b1aa081c..00000000
--- a/src/plugins/qpluginbase.pri
+++ /dev/null
@@ -1,21 +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
-
-symbian: {
- TARGET.EPOCALLOWDLLDATA=1
- TARGET.CAPABILITY = All -Tcb
- TARGET = $${TARGET}$${QT_LIBINFIX}
-}
diff --git a/src/plugins/qt_targets.pri b/src/plugins/qt_targets.pri
deleted file mode 100644
index 8c9a8dd0..00000000
--- 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) 2010 Nokia Corporation and/or its subsidiary(-ies)
diff --git a/src/plugins/sceneformats/3ds/3ds.pro b/src/plugins/sceneformats/3ds/3ds.pro
deleted file mode 100644
index 0dabe5fc..00000000
--- a/src/plugins/sceneformats/3ds/3ds.pro
+++ /dev/null
@@ -1,50 +0,0 @@
-TARGET = qscene3ds
-include(../../qpluginbase.pri)
-include(../../../../pkg.pri)
-HEADERS += qgl3dsloader.h \
- qgl3dsscene.h \
- qgl3dsscenehandler.h \
- qgl3dsmesh.h
-SOURCES += main.cpp \
- qgl3dsloader.cpp \
- qgl3dsscene.cpp \
- qgl3dsscenehandler.cpp \
- qgl3dsmesh.cpp
-
-# See the README in the root dir re this code
-package {
- macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- LIBS += -framework Qt3D -F../../../threed
- INCLUDEPATH += ../../../threed/Qt3D.framework/Versions/1/Headers
- } else {
- win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- LIBS += ..\\..\\..\\threed\\debug\\Qt3Dd.lib
- } else {
- LIBS += ..\\..\\..\\threed\\release\\Qt3D.lib
- }
- } else {
- LIBS += -L../../../threed -lQt3D
- }
- INCLUDEPATH += ../../../../include/Qt3D
- }
- target.path = $$QT3D_INSTALL_PLUGINS/sceneformats]
- INSTALLS += target
-} else {
- CONFIG += qt3d
- DESTDIR = $$QT3D_INSTALL_PLUGINS/sceneformats
-}
-
-system_3ds {
- !isEmpty(QMAKE_INCDIR_3DS):INCLUDEPATH += $$QMAKE_INCDIR_3DS
- !isEmpty(QMAKE_LIBDIR_3DS):LIBS += -L$$QMAKE_LIBDIR_3DS
-
- !isEmpty(QMAKE_LIBS_3DS):LIBS += -l$$QMAKE_LIBS_3DS
- else {
- win32:LIBS += -llib3ds-1_3
- else:LIBS += -l3ds
- }
-} else {
- include(../../../../3rdparty/lib3ds/lib3ds.pri)
-}
diff --git a/src/plugins/sceneformats/3ds/README.txt b/src/plugins/sceneformats/3ds/README.txt
deleted file mode 100644
index 1fa00084..00000000
--- a/src/plugins/sceneformats/3ds/README.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-This implementation of 3D studio max file import relies on the library
-lib3ds available from http://lib3ds.org/. A copy of this library is
-included with Qt/3D, or you can download and build your own version
-as described below.
-
-To enable building and use of the plugin, pass CONFIG+=system_3ds to qmake
-
-Currently version 1.3 is required. Do not use version 2.0 or later as it is incompatible.
-
-For Linux systems typically 1.3 can be obtained by installing a binary package, eg lib3ds-dev
-
-When compiling from source on Unix a simple ./configure, make, make install seems to work fine
-on both linux and mac osx.
-
-On windows with Visual Studio the lib3ds library can be compiled as follows.
-
-1) Download the zipped source of 1.3 and expand it, cd into the directory created.
-
-2) Edit the file msvc8\lib3ds.rc
- -#include "winres.h"
- +#include "WinResrc.h"
-
-3) Locate the vcbuild.exe on the windows system:
-
- // this is needed for VS9
- C:\path\to\vcbuild.exe /upgrade msvc8\lib3ds.vcproj
- C:\path\to\vcbuild.exe msvc8\lib3ds.vcproj
-
-4) Release and debug versions of the library files will be created. Install by:
-
- xcopy msvc8\release\* C:\path\to\bin
- xcopy msvc8\debug\* C:\path\to\bin
-
-To avoid having to install the lib3ds.org library/dll/headers in a path where the compiler
-will locate them, pass the following arguments to qmake:
- QMAKE_LIBDIR_3DS=C:\build\lib3ds\msvc8\release
- QMAKE_INCDIR_3DS=C:\build\lib3ds
-
-If the library is called something different to lib3ds-1_3 on windows or lib3ds.1.3.so on
-Unix, for example to use the debug library on windows pass this argument to qmake:
- QMAKE_LIBS_3DS=lib3ds-1_3d
-
-There is a handy 3dsplay utility in the lib3ds distribution - its not needed for Qt3D but is
-convenient for debugging models.
-
-To build the 3dsplay utility - a command line 3ds viewer that uses GLUT and OpenGL - after
-building and installing lib3ds as above, from the build directory use:
-Linux: gcc -o 3dsplay -lGL -lglut -l3ds examples/3dsplay.c
-MacOSX: gcc -FOpenGL -FGLUT -framework OpenGL -framework GLUT -l3ds -o 3dsplay examples/3dsplay.c
-
-To get image loading support to enable textures, this works on MacSOX:
-First install SDL: http://www.libsdl.org/download-1.2.php
-And SDL_image: http://www.libsdl.org/projects/SDL_image/
- gcc -c -DUSE_SDL -o examples/3dsplay.o -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers examples/3dsplay.c
- gcc -framework SDL_image -framework SDL -framework OpenGL -framework GLUT -l3ds -o 3dsplay examples/3dsplay.o
diff --git a/src/plugins/sceneformats/3ds/main.cpp b/src/plugins/sceneformats/3ds/main.cpp
deleted file mode 100644
index bc2b322d..00000000
--- a/src/plugins/sceneformats/3ds/main.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsceneformatplugin.h"
-#include "qgl3dsscenehandler.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGL3dsScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-
-QStringList QGL3dsScenePlugin::keys() const
-{
- return QStringList() << QLatin1String("3ds") << QLatin1String("application/x-3ds") << QLatin1String("image/x-3ds");
-}
-
-QGLSceneFormatHandler *QGL3dsScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-{
- Q_UNUSED(device);
- Q_UNUSED(url);
- Q_UNUSED(format);
- return new QGL3dsSceneHandler;
-}
-
-Q_EXPORT_STATIC_PLUGIN(QGL3dsScenePlugin)
-Q_EXPORT_PLUGIN2(qscene3ds, QGL3dsScenePlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/3ds/qgl3dsloader.cpp b/src/plugins/sceneformats/3ds/qgl3dsloader.cpp
deleted file mode 100644
index 07690d6d..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsloader.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgl3dsloader.h"
-#include "qglmaterial.h"
-#include "qglmaterialcollection.h"
-#include "qglpainter.h"
-#include "qgltexture2d.h"
-#include "qgl3dsscene.h"
-#include "qglscenenode.h"
-#include "qgl3dsmesh.h"
-
-#include <lib3ds/mesh.h>
-#include <lib3ds/file.h>
-#include <lib3ds/node.h>
-#include <lib3ds/material.h>
-#include <lib3ds/matrix.h>
-
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qfileinfo.h>
-
-QGL3dsLoader::QGL3dsLoader(Lib3dsFile *file, QGL3dsSceneHandler* sh)
- : m_file(file)
- , m_rootNode(new QGLSceneNode())
- , m_scene(sh)
- , m_hasTextures(false)
-{
- m_rootNode->setPalette(new QGLMaterialCollection(m_rootNode));
- m_rootNode->setObjectName(QString::fromLocal8Bit(file->name));
- setUrl(sh->url());
-}
-
-QGL3dsLoader::~QGL3dsLoader()
-{
- // nothing to do here - m_rootNode is taken ownership of by caller of
- // rootNode() method
-}
-
-/*!
- Sets the location for resolving resource paths to \a url.
-
- Only URL's with a "file" scheme are supported.
-*/
-void QGL3dsLoader::setUrl(const QUrl &url)
-{
- // TODO - handling of network URLs
- if (url.scheme() == QLatin1String("file"))
- m_url = url;
- else
- qWarning("QGL3dsLoader::setUrl(%s): ignored, only file urls supported",
- url.encodedPath().constData());
-}
-
-void QGL3dsLoader::loadMesh(Lib3dsMesh *mesh)
-{
-#ifndef QT_NO_DEBUG_STREAM
- if (mesh->points == 0 && (m_scene->options() & QGL::ShowWarnings))
- qDebug() << "Mesh" << mesh->name << "has zero vertex count";
- else if (mesh->faces == 0 && (m_scene->options() & QGL::ShowWarnings))
- qDebug() << "Mesh" << mesh->name << "has zero face count";
-#endif
- QGL3dsMesh m(mesh, m_rootNode->palette());
- QString name = QString::fromLatin1(mesh->name);
- QGL::ModelOptions o = m_scene->meshOptions(name);
- if (o == 0)
- o = m_scene->options();
- m.setOptions(o);
- QGLSceneNode *node;
- if (mesh->faces == 0 || mesh->points == 0)
- {
- node = new QGLSceneNode(m_rootNode);
- node->setObjectName(name);
- m_meshes.insert(name, node);
- return;
- }
- m.initialize();
- if (!m_hasTextures)
- m_hasTextures = m.hasTexture();
- if (!m_hasLitMaterials)
- m_hasLitMaterials = !m.hasTexture();
- node = m.finalizedSceneNode();
- m_meshes.insert(name, node);
- m_rootNode->addNode(node);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-static const char *node_type_names[] = {
- "LIB3DS_UNKNOWN_NODE",
- "LIB3DS_AMBIENT_NODE",
- "LIB3DS_OBJECT_NODE",
- "LIB3DS_CAMERA_NODE",
- "LIB3DS_TARGET_NODE",
- "LIB3DS_LIGHT_NODE",
- "LIB3DS_SPOT_NODE"
-};
-#endif
-
-inline static QMatrix4x4 getNodeMatrix(Lib3dsNode *node)
-{
- QMatrix4x4 nodeMatrix;
- for (int col = 0; col < 4; ++col)
- for (int row = 0; row < 4; ++row)
- nodeMatrix(row, col) = node->matrix[col][row];
- nodeMatrix.optimize();
- Lib3dsObjectData *d = &node->data.object;
- if (!qFuzzyIsNull(d->pivot[0]) || !qFuzzyIsNull(d->pivot[1]) || !qFuzzyIsNull(d->pivot[2]))
- nodeMatrix.translate(-d->pivot[0], -d->pivot[1], -d->pivot[2]);
- return nodeMatrix;
-}
-
-void QGL3dsLoader::loadNodes(Lib3dsNode *nodeList, QGLSceneNode *parentNode)
-{
- Lib3dsNode *node;
- for (node = nodeList; node != NULL; node = node->next)
- {
- if (node->type == LIB3DS_OBJECT_NODE)
- {
- Lib3dsObjectData *d = &node->data.object;
- QString meshName = QString::fromLatin1(d->morph);
- if (meshName.isEmpty())
- meshName = QString::fromLatin1(d->instance);
- if (meshName.isEmpty())
- meshName = QString::fromLatin1(node->name);
- if (!meshName.isEmpty() && m_meshes.contains(meshName))
- {
- QGLSceneNode *mesh = m_meshes[meshName];
- QMatrix4x4 mat = getNodeMatrix(node);
- mat = mat * mesh->localTransform();
- mesh->setLocalTransform(mat);
- }
- else
- {
- QGLSceneNode *sceneNode = new QGLSceneNode(parentNode);
- sceneNode->setPalette(parentNode->palette());
- sceneNode->setLocalTransform(getNodeMatrix(node));
- //sceneNode->userTransform().setToIdentity(); //DP: set matrix to identity so it is initialised in a useful way at least.
- QString nodeName(QString::fromLatin1(node->name));
- if (nodeName == QLatin1String("$$$DUMMY"))
- {
- nodeName = QString::fromLatin1(node->data.object.instance);
- sceneNode->setObjectName(nodeName);
- loadNodes(node->childs, sceneNode);
- }
- }
- }
-#ifndef QT_NO_DEBUG_STREAM
- else
- {
- qDebug() << "Node" << node->name << "of type" << node_type_names[node->type] << "not currently supported";
- }
-#endif
- }
-}
-
-/*!
- \internal
- Loads all the geometry, materials, and texture associations from the assigned
- file, and returns the root node of the resulting scene graph.
-
- The caller must take ownership of the root node returned, and delete it
- when its no longer required.
-*/
-QGLSceneNode *QGL3dsLoader::loadMeshes()
-{
- Q_CHECK_PTR(m_file);
- Lib3dsMaterial *mat;
- for (mat = m_file->materials; mat != NULL; mat = mat->next)
- loadMaterial(mat);
- Lib3dsMesh * mesh;
- for (mesh = m_file->meshes; mesh != NULL; mesh = mesh->next)
- loadMesh(mesh);
- QGL::MeshOptionMap optList = m_scene->meshOptions();
- QStringList optionedMeshes = optList.keys();
- QStringList gotMeshes = m_meshes.keys();
- for (int i = 0; i < gotMeshes.size(); ++i)
- optionedMeshes.removeAll(gotMeshes.at(i));
- for (int i = 0; i < optionedMeshes.size(); ++i)
- qWarning("Option specified, but mesh %s not found",
- qPrintable(optionedMeshes.at(i)));
- m_rootNode->palette()->removeUnusedMaterials();
- loadNodes(m_file->nodes, m_rootNode);
- m_rootNode->setEffect(m_hasTextures ? QGL::LitModulateTexture2D : QGL::LitMaterial);
- return m_rootNode;
-}
-
-/*!
- \internal
- Search for a resource based on the given \a path.
-
- If the URL for the currently loading mesh has a scheme other than
- "file" then a URL with the path relative to that URL is returned.
-
- If the URL for the currently loading mesh has a "file" scheme, then
- first a case-sensitive search is done of all of the current directory,
- and the :/ resource directory, and the directory of the current mesh
- file.
-
- If the file is not found in any of those locations then they are
- searched again case-insensitively. If the file is found, then a
- URL based on the absolute file path of the matching file is returned.
-
- Otherwise an empty string is returned.
-*/
-QUrl QGL3dsLoader::ensureResource(const QString &path)
-{
- QUrl res;
- if (m_url.scheme() == QLatin1String("file"))
- {
- res = m_url.resolved(path);
- if (QFile::exists(res.path())) // shortcut common case
- return res;
- QStringList paths;
- paths << QLatin1String(".") << QLatin1String(":/"); // current directory and aliased/root resource file
- if (!m_url.isEmpty())
- {
- QFileInfo fi(m_url.path());
- paths.prepend(fi.absoluteDir().absolutePath());
- }
- bool caseInsensitive = false;
- do {
- QStringList::const_iterator it(paths.begin());
- for ( ; it != paths.end(); ++it)
- {
- QDir resDir(*it);
- QStringList fileList = resDir.entryList(QDir::Files);
- if (caseInsensitive)
- {
- QStringList::const_iterator fit(fileList.begin());
- for ( ; fit != fileList.end(); ++fit)
- {
- if (fit->toLower() == path.toLower())
- {
- res.setScheme(QLatin1String("file"));
- res.setPath(resDir.absoluteFilePath(*fit));
- break;
- }
- }
- }
- else
- {
- if (fileList.contains(path))
- {
- //return resDir.absoluteFilePath(path);
- res.setScheme(QLatin1String("file"));
- res.setPath(resDir.absoluteFilePath(path));
- break;
- }
- }
- }
- if (caseInsensitive)
- break;
- caseInsensitive = true;
- } while (true);
- }
- else
- {
- // non-file url
- res = m_url.resolved(path);
- }
- return res;
-}
-
-/*!
- Load a material
-*/
-void QGL3dsLoader::loadMaterial(Lib3dsMaterial *mat3ds)
-{
- QGLMaterialCollection *palette = m_rootNode->palette();
- QGLMaterial *mat = new QGLMaterial();
- Lib3dsRgba &amb = mat3ds->ambient;
- Lib3dsRgba &dif = mat3ds->diffuse;
- Lib3dsRgba &spc = mat3ds->specular;
- mat->setAmbientColor(QColor::fromRgbF(amb[0], amb[1], amb[2], amb[3]));
- mat->setDiffuseColor(QColor::fromRgbF(dif[0], dif[1], dif[2], dif[3]));
- mat->setSpecularColor(QColor::fromRgbF(spc[0], spc[1], spc[2], spc[3]));
- mat->setShininess(128 * mat3ds->shininess);
- mat->setObjectName(QString::fromLatin1(mat3ds->name));
- palette->addMaterial(mat);
- if (mat3ds->texture1_map.name[0])
- {
- QString txName(QString::fromLatin1(mat3ds->texture1_map.name));
- QUrl url = ensureResource(txName);
- if (url.isEmpty())
- {
- if (m_scene->options() & QGL::ShowWarnings)
- qWarning("Could not load texture: %s", mat3ds->texture1_map.name);
- }
- else
- {
- mat->setTextureUrl(url);
- }
- }
-}
diff --git a/src/plugins/sceneformats/3ds/qgl3dsloader.h b/src/plugins/sceneformats/3ds/qgl3dsloader.h
deleted file mode 100644
index 696e31b7..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsloader.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSLOADER_H
-#define QGL3DSLOADER_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qmap.h>
-
-class Lib3dsFile;
-class Lib3dsMesh;
-class Lib3dsMaterial;
-class Lib3dsNode;
-class QGL3dsMesh;
-class QGLSceneNode;
-class QGL3dsSceneHandler;
-
-class QGL3dsLoader
-{
-public:
- QGL3dsLoader(Lib3dsFile *file, QGL3dsSceneHandler* sh);
- ~QGL3dsLoader();
- QGLSceneNode *loadMeshes();
-
-private:
- void loadMesh(Lib3dsMesh *);
- void loadNodes(Lib3dsNode *, QGLSceneNode *);
- void loadMaterial(Lib3dsMaterial *);
- QUrl ensureResource(const QString &);
- void setUrl(const QUrl &url);
-
- Lib3dsFile *m_file;
- QGLSceneNode *m_rootNode;
- QGL3dsSceneHandler *m_scene;
- QList<QGLSceneNode *> m_nodes;
- QMap<QString, QGLSceneNode *> m_meshes;
- QUrl m_url;
- bool m_hasTextures;
- bool m_hasLitMaterials;
-};
-
-#endif // QGL3DSLOADER_H
diff --git a/src/plugins/sceneformats/3ds/qgl3dsmesh.cpp b/src/plugins/sceneformats/3ds/qgl3dsmesh.cpp
deleted file mode 100644
index 97b72f71..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsmesh.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgl3dsmesh.h"
-#include "qglmaterialcollection.h"
-#include "qglsection_p.h"
-#include "qarray.h"
-#include "qvector_utils_p.h"
-
-#include <lib3ds/mesh.h>
-#include <lib3ds/material.h>
-#include <lib3ds/vector.h>
-#include <lib3ds/types.h>
-
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qmath.h>
-
-// Faceted meshes look terrible when they have more than a small number
-// of faces. Usually if large meshes are faceted its some kind of error
-// in the model, or in importing of the model by lib3ds. Force on
-// smoothing when greater than this many faces are detected.
-#define FACETED_THRESHOLD 1000
-
-// Two faces that have an angle between their plane vectors with a cosine
-// less than this are judged to form a sharp (acute) angle.
-// -ve cosine (less than 0.0f) means 90 degrees or sharper like the sides
-// of a rectangular prism so this is a good value.
-#define ACUTE -0.0001f
-
-// Two vectors that have an angle between them with a cosine less than this
-// value are judged to be approximately the inverse of each other, for the
-// purposes of determining whether a normal has been inverted or not
-#define INVERSE -0.20f
-
-// Only try to correct normals if this many neighbour faces contribute to
-// the assessment. 2 or 3 are good values. 4 or greater is the same as
-// defining DO_NORMAL_CORRECT false
-#define AVG_CNT 2
-
-// make a QVector3D from a Lib3dsVector - by a hard cast. Its required
-// that QVector3D behave like a POD type - float[3] - for all of the
-// OpenGL stuff
-static inline QVector3D &l2v(Lib3dsVector &vec)
-{
- return reinterpret_cast<QVector3D&>(vec);
-}
-
-// is this a null 3ds vector - same as QVector3D::isNull()
-static inline bool qIsNull(const Lib3dsVector &vec)
-{
- return (qIsNull(vec[0]) && qIsNull(vec[1]) && qIsNull(vec[2]));
-}
-
-static inline bool qFskCompare(const Lib3dsVector &a, const Lib3dsVector &b)
-{
- return (qFskCompare(a[0], b[0]) && qFskCompare(a[1], b[1]) && qFskCompare(a[2], b[2]));
-}
-
-// find the normalized plane vector, that is a unit vector perpendicular
-// to the plane of the face. this is the same thing as the default normal
-static inline void planeVec(Lib3dsFace *face, Lib3dsPoint *pointList, Lib3dsVector result)
-{
- Lib3dsVector &l3a = pointList[face->points[0]].pos;
- Lib3dsVector &l3b = pointList[face->points[1]].pos;
- Lib3dsVector &l3c = pointList[face->points[2]].pos;
- lib3ds_vector_normal(result, l3a, l3b, l3c);
-}
-
-struct ModulateRecord
-{
- bool disabled;
- bool keyFresh;
- int facesProcessed;
- int numModulated;
- Lib3dsDword altKey;
- Lib3dsDword key;
-};
-
-QGL3dsMesh::QGL3dsMesh(Lib3dsMesh *mesh, QGLMaterialCollection *materials)
- : QGLBuilder(materials)
- , m_mesh(mesh)
- , m_texFlip(false)
- , m_hasZeroSmoothing(false)
- , m_faceMap(0)
-{
-}
-
-QGL3dsMesh::~QGL3dsMesh()
-{
- delete[] m_faceMap;
-}
-
-void QGL3dsMesh::processNodeForMaterial(int matIx, QGLSceneNode *node)
-{
- QGLSceneNode *s = sceneNode();
- QString baseName = s->objectName();
- node->setMaterialIndex(matIx);
- node->setObjectName(baseName + QLatin1String("::") +
- ((matIx == -1)
- ? QLatin1String("No_Material")
- : s->palette()->materialName(matIx)));
- checkTextures(matIx);
- generateVertices();
- s->palette()->markMaterialAsUsed(matIx);
-}
-
-void QGL3dsMesh::initAdjacencyMap()
-{
- Lib3dsFace *face;
- m_faceMap = new FacePtr[m_mesh->faces * 3];
- qMemSet(m_faceMap, 0, sizeof(m_faceMap));
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- {
- face = &m_mesh->faceL[f];
- planeVec(face, m_mesh->pointL, face->normal);
- m_mesh->faceL[f].user.p = &m_faceMap[f*3];
- }
-}
-
-void QGL3dsMesh::initialize()
-{
- QGLSceneNode *s = sceneNode();
- s->setObjectName(QString::fromLatin1(m_mesh->name));
- if ((m_options & QGL::ForceSmooth) && (m_options & QGL::ForceFaceted))
- {
- if (m_options & QGL::ShowWarnings)
- qWarning("Both smooth and faceted forced on for %s: forcing smooth\n",
- m_mesh->name);
- m_options &= ~QGL::ForceFaceted;
- }
- initAdjacencyMap();
- if (m_options & (QGL::CorrectNormals | QGL::CorrectAcute))
- modulateMesh();
- analyzeMesh();
-
- if (m_smoothingGroups == 0)
- {
- bool forceSmooth = (m_options & QGL::ForceSmooth);
- if (!forceSmooth && m_mesh->faces > FACETED_THRESHOLD)
- {
- if (m_options & QGL::ShowWarnings)
- qWarning("Mesh %s has %d faces (threshold is %d):"
- "forcing smooth render", m_mesh->name, m_mesh->faces,
- FACETED_THRESHOLD);
- forceSmooth = true;
- }
- if (forceSmooth)
- {
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- m_mesh->faceL[f].smoothing = 1;
- analyzeMesh();
- }
- }
-
- bool mixedTexturedAndPlain = m_plainMaterials.count() > 0 &&
- m_textureMaterials.count() > 0;
-
- s->setLocalTransform(meshMatrix());
-
- // start a new section and node
- newSection(m_smoothingGroups ? QGL::Smooth : QGL::Faceted);
- QGLSceneNode *node = currentNode();
-
- // process all the plain materials first, then textured to avoid effect swapping
- QList<int> matList = m_plainMaterials.toList();
- if (mixedTexturedAndPlain)
- {
- node->setEffect(QGL::LitMaterial);
- node->setObjectName(s->objectName() + QLatin1String("::Materials"));
- //qDebug() << ">>> mixed:" << node;
- pushNode();
- //qDebug() << " pushed - current now:" << currentNode();
- }
- else
- {
- s->setEffect(m_textureMaterials.count() > 0 ? QGL::LitModulateTexture2D : QGL::LitMaterial);
- }
- //qDebug() << "processing:" << matList.count() << "materials";
- while (matList.count() > 0)
- {
- int matIx = matList.takeFirst();
- processNodeForMaterial(matIx, node);
- if (matList.count() > 0)
- node = newNode();
- }
- matList = m_textureMaterials.toList();
- if (mixedTexturedAndPlain)
- {
- //qDebug() << "<<< mixed:" << currentNode();
- popNode();
- //qDebug() << " popped - current now:" << currentNode();
- node = currentNode();
- node->setEffect(QGL::LitModulateTexture2D);
- node->setObjectName(s->objectName() + QLatin1String("::Textures"));
- }
- while (matList.count() > 0)
- {
- int matIx = matList.takeFirst();
- processNodeForMaterial(matIx, node);
- if (matList.count() > 0)
- node = newNode();
- }
-}
-
-// Build a linked list, in a QArray: the first N*2 entries correspond
-// to the N vertices: for each n'th vertex, n*2 is the face number,
-// n*2+1is the index of the next entry for that vertex, or -1 if there
-// is no next entry.
-//
-// While on the job find the smoothing keys and store in allKeys.
-//
-// And zero out the user data pointer for each face, and calculate the
-// smoothing group count.
-QArray<int> QGL3dsMesh::mapFacesToVerts(Lib3dsDword *allKeys)
-{
- Lib3dsFace *face;
- QArray<int> vlist(m_mesh->points * 2, -1);
- int nx = 2 * m_mesh->points;
- m_smoothingGroupCount = 0;
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- {
- face = &m_mesh->faceL[f];
- if (face->smoothing)
- {
- if (!(face->smoothing & *allKeys))
- {
- *allKeys |= face->smoothing;
- m_smoothingGroupCount += 1;
- }
- }
- for (int i = 0; i < 3; ++i)
- {
- int v = face->points[i];
- int ptr = v*2;
- int prv = -1;
- if (vlist[ptr] != -1)
- {
- prv = ptr;
- while (vlist[ptr+1] != -1)
- {
- ptr = vlist[ptr+1];
- prv = ptr;
- }
- ptr = nx;
- vlist.extend(2);
- nx += 2;
- }
- vlist[ptr] = f;
- vlist[ptr+1] = -1;
- if (prv != -1)
- vlist[prv+1] = ptr;
- }
- }
- return vlist;
-}
-
-void QGL3dsMesh::addToAdjacencyMap(Lib3dsFace *face, Lib3dsFace *neighbour)
-{
- Q_ASSERT(face);
- Q_ASSERT(face->user.p);
- Q_ASSERT(neighbour);
- FacePtr *h = static_cast<FacePtr*>(face->user.p);
- while (*h != 0)
- ++h;
- *h = neighbour;
-}
-
-// add to each face a linked list of its <= 3 neighbouring faces
-// and also ensure each face knows is own normal. Rather than doing
-// lots of small allocs, just assume every face has 3 neighbours
-// and allocate the list nodes in one big lump - the m_faceMap.
-// use the user data pointer in the lib3ds face struct to point
-// to the first node in the list.
-void QGL3dsMesh::buildAdjacencyMap(const QArray<int> &vlist)
-{
- Lib3dsFace *face;
- Lib3dsFace *nbr;
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- {
- // for each edge (where an edge is a pair of verts) find ones
- // adjacent, ie both verts in edge have same face (which is
- // not this face).
- face = &m_mesh->faceL[f];
- for (int i = 0; i < 3; ++i)
- {
- Q_ASSERT(face->points[i] < m_mesh->points);
- int vi = 2 * face->points[i];
- int neighbouri = -1;
- while (true)
- {
- neighbouri = vlist[vi];
- if (neighbouri != (int)f)
- {
- Q_ASSERT(face->points[(i + 1) % 3] < m_mesh->points);
- int vj = 2 * face->points[(i + 1) % 3];
- int neighbourj = -1;
- while (true)
- {
- neighbourj = vlist[vj];
- if (neighbourj == neighbouri)
- {
- nbr = &m_mesh->faceL[neighbouri];
- // only add as neighbour if at least one smoothing group
- // is shared - still have to test again below for each group
- if (nbr->smoothing & face->smoothing)
- addToAdjacencyMap(face, nbr);
- break;
- }
- if (vlist[vj+1] == -1)
- break;
- vj = vlist[vj+1];
- }
- }
- if (vlist[vi+1] == -1)
- break;
- else
- vi = vlist[vi+1];
- }
- }
- }
-}
-
-static inline void incOrWarn(ModulateRecord *mod)
-{
- if (mod->altKey != 0x80000000)
- {
- mod->altKey <<= 1;
- }
- else
- {
- qWarning("Overflowed smoothing keys - modulation disabled.");
- mod->disabled = true;
- }
-}
-
-static inline void nextUnusedKey(ModulateRecord *mod, const Lib3dsDword &allKeys)
-{
- if (!mod->disabled)
- {
- if (mod->altKey != 0)
- incOrWarn(mod);
- else
- {
- mod->altKey = 1; // initialize
- }
- while ((mod->altKey & allKeys) && !mod->disabled)
- {
- incOrWarn(mod);
- }
- mod->keyFresh = true;
- }
-}
-
-static int numCorrected = 0;
-static int numWindingCorrected = 0;
-
-static inline void doNormalCorrect(Lib3dsFace *face)
-{
- QGL3dsMesh::FacePtr *n = reinterpret_cast<QGL3dsMesh::FacePtr*>(face->user.p);
- int acnt = 0;
- Lib3dsVector avgn = { 0 };
- for (; *n; ++n)
- {
- if ((*n)->smoothing & face->smoothing)
- {
- lib3ds_vector_add(avgn, avgn, (*n)->normal);
- ++acnt;
- }
- }
- if (acnt >= AVG_CNT)
- {
- lib3ds_vector_normalize(avgn);
- float na = lib3ds_vector_dot(face->normal, avgn);
- if (na < INVERSE)
- {
- //qWarning("corrected: %p - %d, %d, %d", face,
- // face->points[0], face->points[1], face->points[2]);
- //lib3ds_vector_dump(face->normal);
- lib3ds_vector_neg(face->normal);
- numWindingCorrected++;
- qSwap(face->points[1], face->points[2]);
- }
- }
-}
-
-static inline void modFace(Lib3dsFace *face, ModulateRecord *mod)
-{
- ++mod->numModulated;
- face->smoothing &= ~mod->key; // remove old key
- face->smoothing |= mod->altKey; // add in new key
- ::strncpy(face->material, "bright-red", 60); //debug
-}
-
-static inline void doModulate(Lib3dsFace *face, ModulateRecord *mod)
-{
- QGL3dsMesh::FacePtr *n = reinterpret_cast<QGL3dsMesh::FacePtr*>(face->user.p);
- ++mod->facesProcessed;
- for ( ; *n; ++n)
- {
- QGL3dsMesh::FacePtr neighbour = *n;
- if (neighbour->smoothing & face->smoothing)
- {
- if (lib3ds_vector_dot(face->normal, neighbour->normal) < ACUTE)
- {
- qWarning("Modulated due to ACUTE\n");
- modFace(neighbour, mod);
- mod->keyFresh = false;
- }
- }
- }
-}
-
-bool operator<(const QVector3D &a, const QVector3D &b)
-{
- if (qFskCompare(a.x(), b.x()))
- {
- if (qFskCompare(a.y(), b.y()))
- {
- if (qFskCompare(a.z(), b.z()))
- {
- return false; // they're equal a is not less than b
- }
- else
- {
- return a.z() < b.z();
- }
- }
- else
- {
- return a.y() < b.y();
- }
- }
- else
- {
- return a.x() < b.x();
- }
-}
-
-// Go thru each smoothing group - we don't care about the zero group since
-// they're already faceted. In each group process all connected faces
-// starting the queue off with a seed face (the first face in the group).
-// Set the alternate group to be the first unused smoothing group key.
-//
-// To process a face: add the face to the processed set; for each adjacent
-// face if its in this same smoothing group, add it to the queue.
-//
-// Modulate smoothing mode: if an adjacent face is at an acute angle to this
-// face, move it to the alternate group. Note that the alternate groups are
-// not further iterated since they are not in "each smoothing group"
-// (the allKeys variable).
-//
-// When the queue is empty, go to the next smoothing group in the mesh.
-
-// Normal repair mode: if a face normal is flipped in error, ie a mistake
-// in model building (typically points specified in the wrong order)
-// this can be detected and repaired. The normal is flipped if the inverse
-// of the normal is at an acute angle to the average of neighbour normals.
-// If detected the normals is corrected and the winding is also checked to
-// see if it needs to be corrected also.
-void QGL3dsMesh::modulateMesh()
-{
- if (!(m_options & (QGL::CorrectNormals | QGL::CorrectAcute)))
- return;
- FacePtr face;
- Lib3dsDword allKeys = 0;
- QArray<int> vlist = mapFacesToVerts(&allKeys);
- buildAdjacencyMap(vlist);
- QSet<FacePtr> processed;
- ModulateRecord mod;
- qMemSet(&mod, 0, sizeof(struct ModulateRecord));
- mod.key = 1;
- while ((mod.key < allKeys) && !mod.disabled && mod.key)
- {
- if (!(allKeys & mod.key))
- {
- ++mod.key;
- continue;
- }
- QArray<FacePtr> queue;
- Lib3dsDword fptr = 0;
- int head = 0;
- while (true)
- {
- if (head >= queue.size()) // seed another island of faces
- {
- if (!mod.keyFresh && head > 0) // if not first time thru, did we use last key?
- allKeys = allKeys | mod.altKey;
- FacePtr qf = 0;
- for ( ; fptr < m_mesh->faces; ++fptr)
- {
- qf = &m_mesh->faceL[fptr];
- if ((mod.key & qf->smoothing) && !processed.contains(qf))
- break;
- }
- if (fptr == m_mesh->faces)
- break;
- queue.append(qf);
- if (!mod.keyFresh)
- {
- nextUnusedKey(&mod, allKeys);
- if (mod.disabled)
- break;
- }
- }
- face = queue.at(head++);
- processed.insert(face);
- doNormalCorrect(face);
- doModulate(face, &mod);
- FacePtr *n = reinterpret_cast<FacePtr*>(face->user.p);
- for ( ; *n; ++n)
- if ((mod.key & (*n)->smoothing) && !processed.contains(*n))
- queue.append(*n);
- }
- }
- if ((m_options & QGL::CorrectNormals) && (m_options & QGL::ShowWarnings))
- qDebug() << "CorrectNormals mode:" << numCorrected << "normals corrected.";
- if ((m_options & QGL::CorrectAcute) && (m_options & QGL::ShowWarnings))
- qDebug() << "CorrectAcute mode:" << mod.numModulated << "normals corrected";
-}
-
-int QGL3dsMesh::cachedMaterialLookup(const char *material)
-{
- static bool initialized = false;
- static int lastLookup = -1;
- static char lastName[512];
- if (!initialized)
- {
- ::memset(lastName, 0, 512);
- initialized = true;
- }
- if (qstrncmp(lastName, material, 510) != 0)
- {
- lastLookup = sceneNode()->palette()->indexOf(QString::fromLatin1(material));
- qstrncpy(lastName, material, 510);
- }
- return lastLookup;
-}
-
-/*!
- \internal
- Find material indexes and smoothing groups used in this mesh. If any
- face has no material assigned then a -1 index will be listed.
- Also figures out how complex the mesh is, by finding the count of
- smoothing groups for the material with the greatest number of groups.
- If the mesh is faceted (no smoothing) but has greater than FACETED_THRESHOLD
- faces then smoothing is forced on and the mesh rescanned.
-
-*/
-void QGL3dsMesh::analyzeMesh()
-{
- QGLMaterialCollection *pal = sceneNode()->palette();
- Lib3dsFace *face;
- Lib3dsDword allKeys = 0;
- m_smoothingGroupCount = 0;
- m_hasZeroSmoothing = false;
- m_plainMaterials.clear();
- m_textureMaterials.clear();
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- {
- face = &m_mesh->faceL[f];
- int matIx = cachedMaterialLookup(face->material);
-#ifndef QT_NO_DEBUG_STREAM
- if (matIx == -1 && strlen(face->material) != 0 && (m_options & QGL::ShowWarnings))
- qDebug("Bad .3ds file: no material %s! (Referenced in mesh %s)\n",
- face->material, m_mesh->name);
-#endif
- if (face->smoothing)
- {
- if ((face->smoothing & allKeys) != face->smoothing)
- {
- Lib3dsDword key = 1;
- while (key)
- {
- if ((key & face->smoothing) && !(allKeys & key))
- {
- allKeys = allKeys | key;
- m_smoothingGroupCount += 1;
- }
- key <<= 1;
- }
- }
- }
- else
- {
- m_hasZeroSmoothing = true;
- }
- if (!m_plainMaterials.contains(matIx) && !m_textureMaterials.contains(matIx))
- {
- QGLMaterial *mat = pal->material(matIx);
- if (mat && mat->texture())
- m_textureMaterials.insert(matIx);
- else
- m_plainMaterials.insert(matIx);
- }
- }
- m_smoothingGroups = allKeys;
-}
-
-/*!
- \internal
- Check the meshes textures and update the record of whether this mesh
- has textures or not. In debug mode issue a warning if the textures are
- corrupt (number of texels and vertices not equal).
-*/
-void QGL3dsMesh::checkTextures(int material)
-{
- QGLMaterial *mat = sceneNode()->palette()->material(material);
- QGLTexture2D *tex = (mat ? mat->texture() : 0);
- m_hasTextures = false;
- if (tex)
- {
- m_hasTextures = true;
-#ifndef QT_NO_DEBUG_STREAM
- if (m_mesh->points != m_mesh->texels)
- qWarning("Mesh %s has unequal number of texels (%d) and vertices (%d)",
- m_mesh->name, m_mesh->texels, m_mesh->points);
-#endif
- // all texture coordinates from 3ds have to be flipped because
- // 3ds uses the correct coordinate system, whilst qt uses
- // upside-down coordinates
- m_texFlip = (tex->bindOptions() & QGLContext::InvertedYBindOption) == 0;
- }
-}
-
-/*!
- \internal
- Returns any local transformation matrix for the mesh.
-*/
-QMatrix4x4 QGL3dsMesh::meshMatrix() const
-{
- Lib3dsMatrix &m = m_mesh->matrix; // typedef for float[4][4]
- QMatrix4x4 mat;
- for (int col = 0; col < 4; ++col)
- for (int row = 0; row < 4; ++row) {
- float e = m[col][row];
- if (qFuzzyIsNull(e))
- mat(row, col) = 0.0f;
- else
- mat(row, col) = e;
- }
- mat.optimize(); // setup to use optimizations
- if (mat.isIdentity())
- return mat;
- // The reverse transform is what we apply to model-view in order
- // to draw the underlying geometry
- bool invertible = true;
- mat = mat.inverted(&invertible);
- if (invertible)
- return mat;
- if (m_options & QGL::ShowWarnings)
- qWarning("Could not invert matrix for mesh %s", m_mesh->name);
- return QMatrix4x4();
-}
-
-/*!
- \internal
- Generate the vertices for the faces based on their smoothing keys and
- the current nodes material.
-*/
-void QGL3dsMesh::generateVertices()
-{
- int matIx = currentNode()->materialIndex();
- int keyCount = m_smoothingGroupCount;
- if (m_hasZeroSmoothing)
- ++keyCount;
- QString baseName = currentNode()->objectName();
- Lib3dsDword key = 0;
- while (key <= m_smoothingGroups)
- {
- if ((key & m_smoothingGroups) || ((key == 0) && m_hasZeroSmoothing))
- {
- if (key == 0)
- currentSection()->setSmoothing(QGL::Faceted);
- keyCount -= 1;
- currentNode()->setMaterialIndex(matIx);
- currentNode()->setObjectName(baseName + QLatin1String("::") + QString::number(key));
- QGeometryData tri;
- int cur = 0;
- for (Lib3dsDword f = 0; f < m_mesh->faces; ++f)
- {
- Lib3dsFace *face = &m_mesh->faceL[f];
- int faceMat = cachedMaterialLookup(face->material);
- if (faceMat == matIx &&
- ((key & face->smoothing) || (key == 0 && face->smoothing == 0)))
- {
- QVector3D norm = l2v(face->normal);
- for (int i = 0; i < 3; ++i)
- {
- int a = face->points[i];
- Lib3dsVector &l3a = m_mesh->pointL[a].pos;
- tri.appendVertex(l2v(l3a));
- tri.appendNormal(norm);
- if (m_hasTextures)
- {
- Lib3dsTexel &t0 = m_mesh->texelL[a];
- tri.appendTexCoord(QVector2D(t0[0], m_texFlip ? 1.0f - t0[1] : t0[1]));
- }
- if (m_options & QGL::NativeIndices)
- currentSection()->appendSmooth(tri.logicalVertexAt(cur++), a);
- }
- }
- }
- if (m_options & QGL::NativeIndices)
- currentNode()->setCount(cur);
- else
- addTriangles(tri);
- if (keyCount > 0)
- newSection(QGL::Smooth);
- else
- break;
- }
- if (key == 0)
- key = 1;
- else
- key <<= 1;
- }
-}
diff --git a/src/plugins/sceneformats/3ds/qgl3dsmesh.h b/src/plugins/sceneformats/3ds/qgl3dsmesh.h
deleted file mode 100644
index 2f2985d9..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsmesh.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSMESH_H
-#define QGL3DSMESH_H
-
-#include "qglbuilder.h"
-#include "qgl3dsscenehandler.h"
-
-#include <lib3ds/types.h>
-#include <lib3ds/mesh.h>
-
-class QGLMaterialCollection;
-class QGL3dsLoader;
-class Lib3dsMesh;
-class ModulateRecord;
-
-class QGL3dsMesh : public QGLBuilder
-{
-public:
- explicit QGL3dsMesh(Lib3dsMesh *mesh, QGLMaterialCollection *materials);
- virtual ~QGL3dsMesh();
- void initialize();
- void setOptions(QGL::ModelOptions options) { m_options = options; }
- bool hasTexture() { return m_hasTextures; }
-
- typedef Lib3dsFace *FacePtr;
-
-protected:
- void analyzeMesh();
- void modulateMesh();
- void checkTextures(int);
- QMatrix4x4 meshMatrix() const;
- void generateVertices();
-
-private:
- void processNodeForMaterial(int matIx, QGLSceneNode *node);
- QArray<int> mapFacesToVerts(Lib3dsDword *allKeys);
- void addToAdjacencyMap(Lib3dsFace *face, Lib3dsFace *nbr);
- void buildAdjacencyMap(const QArray<int> &vlist);
- int cachedMaterialLookup(const char *material);
- void findCommonNormal(ModulateRecord *mod) const;
- void initAdjacencyMap();
-
- Lib3dsMesh *m_mesh;
- bool m_hasTextures;
- Lib3dsDword m_smoothingGroups;
- int m_smoothingGroupCount;
- QSet<int> m_plainMaterials;
- QSet<int> m_textureMaterials;
- bool m_texFlip;
- bool m_hasZeroSmoothing;
- FacePtr *m_faceMap;
- QGL::ModelOptions m_options;
-};
-
-#endif // QGL3DSMESH_H
diff --git a/src/plugins/sceneformats/3ds/qgl3dsscene.cpp b/src/plugins/sceneformats/3ds/qgl3dsscene.cpp
deleted file mode 100644
index ec1f95fc..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsscene.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgl3dsscene.h"
-
-#include "qglscenenode.h"
-#include "qgl3dsmesh.h"
-#include "qgl3dsloader.h"
-
-#include <lib3ds/file.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QGL3dsScene
- \brief The QGL3dsScene class manages and contains a 3ds scene.
- The scene consists of a QGLSceneNode object which is the top-level node
- and references the geometry in a 3D Studio Max ".3ds" file. That top
- level node references sub-nodes
-*/
-
-/*!
- \internal
- Construct a new QGL3dsScene object using the data in the \a file,
- and setting the given \a parent. Resources are searched for at the
- given \a url.
-
- The QGL3dsScene object takes ownership of the \a file.
-*/
-QGL3dsScene::QGL3dsScene(Lib3dsFile *file, QGL3dsSceneHandler *h)
- : QGLAbstractScene(0)
- , mFile(file)
-{
- Q_ASSERT(h);
- Q_ASSERT(file);
- QGL3dsLoader loader(file, h);
- mRootNode = loader.loadMeshes();
-}
-
-/*!
- \reimp
- Destroy this QGL3dsScene, recovering all resources.
-
- This method destroys the Lib3dsFile object the scene is based
- on by calling the appropriate lib3ds function.
-*/
-QGL3dsScene::~QGL3dsScene()
-{
- lib3ds_file_free(mFile);
-}
-
-/*!
- \internal
- \reimp
-*/
-QList<QObject *> QGL3dsScene::objects() const
-{
- QList<QObject *> objs;
- if (!mRootNode)
- return objs;
- objs.append(mRootNode);
- QList<QGLSceneNode*> children = mRootNode->allChildren();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for ( ; it != children.constEnd(); ++it)
- objs.append(*it);
- return objs;
-}
-
-/*!
- \internal
- \reimp
-*/
-QGLSceneNode *QGL3dsScene::mainNode() const
-{
- return mRootNode;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/3ds/qgl3dsscene.h b/src/plugins/sceneformats/3ds/qgl3dsscene.h
deleted file mode 100644
index f1fbda8a..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsscene.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSSCENE_H
-#define QGL3DSSCENE_H
-
-#include "qglabstractscene.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-#include <QtCore/qurl.h>
-
-class QGLSceneNode;
-class QGLSceneNode;
-class QGL3dsSceneHandler;
-class Lib3dsFile;
-
-class QGL3dsScene : public QGLAbstractScene
-{
- Q_OBJECT
-public:
- explicit QGL3dsScene(Lib3dsFile *file, QGL3dsSceneHandler *h);
- virtual ~QGL3dsScene();
-
- QList<QObject *> objects() const;
- QGLSceneNode *mainNode() const;
-
- QUrl url() const { return mUrl; }
-
-private:
- Lib3dsFile *mFile;
- QUrl mUrl;
- QGLSceneNode *mRootNode;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/sceneformats/3ds/qgl3dsscenehandler.cpp b/src/plugins/sceneformats/3ds/qgl3dsscenehandler.cpp
deleted file mode 100644
index 5358774b..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsscenehandler.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgl3dsscenehandler.h"
-#include "qgl3dsscene.h"
-
-#include <lib3ds/file.h>
-#include <lib3ds/io.h>
-#include <lib3ds/mesh.h>
-#include <lib3ds/node.h>
-
-#include <QtCore/qdir.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-struct IODevice3ds
-{
- QIODevice *dev;
- bool errorState;
-
-};
-
-extern "C" {
- static Lib3dsBool qgl3ds_fileio_error_func(void *self)
- {
- IODevice3ds *io3d = (IODevice3ds*)self;
- return io3d->errorState;
- }
-
- static long qgl3ds_fileio_seek_func(void *self, long offset, Lib3dsIoSeek origin)
- {
- IODevice3ds *io3d = (IODevice3ds*)self;
- // cannot deal with sockets right now
- Q_ASSERT(!io3d->dev->isSequential());
- switch (origin)
- {
- case LIB3DS_SEEK_SET:
- io3d->errorState = io3d->dev->seek(offset);
- break;
- case LIB3DS_SEEK_CUR:
- io3d->errorState = io3d->dev->seek(io3d->dev->pos() + offset);
- break;
- case LIB3DS_SEEK_END:
- io3d->errorState = io3d->dev->seek(io3d->dev->size() + offset);
- break;
- default:
- Q_ASSERT(0);
- return(0);
- }
- if (io3d->errorState)
- return -1;
- return io3d->dev->pos();
- }
-
- static long qgl3ds_fileio_tell_func(void *self)
- {
- IODevice3ds *io3d = (IODevice3ds*)self;
- return io3d->dev->pos();
- }
-
- static size_t qgl3ds_fileio_read_func(void *self, void *buffer, size_t size)
- {
- IODevice3ds *io3d = (IODevice3ds*)self;
- qint64 result = io3d->dev->read((char*)buffer, size);
- io3d->errorState = (result == -1);
- if (io3d->errorState)
- qWarning("3ds io error: %s\n", io3d->dev->errorString().toLocal8Bit().constData());
- return result;
- }
-
- static size_t qgl3ds_fileio_write_func(void *self, const void *buffer, size_t size)
- {
- IODevice3ds *io3d = (IODevice3ds*)self;
- qint64 result = io3d->dev->write((char*)buffer, size);
- io3d->errorState = (result == -1);
- if (io3d->errorState)
- qWarning("3ds io error: %s\n", io3d->dev->errorString().toLocal8Bit().constData());
- return result;
- }
-}
-
-static Lib3dsFile *qgl3ds_lib3ds_file_load(QIODevice *iod)
-{
- Lib3dsFile *file;
- Lib3dsIo *io;
- Q_ASSERT(iod->isOpen() && iod->isReadable());
- file = lib3ds_file_new();
- if (!file) {
- iod->close();
- return(0);
- }
- IODevice3ds io3d;
- io3d.dev = iod;
- io3d.errorState = false;
- io = lib3ds_io_new(
- &io3d,
- qgl3ds_fileio_error_func,
- qgl3ds_fileio_seek_func,
- qgl3ds_fileio_tell_func,
- qgl3ds_fileio_read_func,
- qgl3ds_fileio_write_func
- );
- if (!io) {
- lib3ds_file_free(file);
- iod->close();
- return(0);
- }
- if (!lib3ds_file_read(file, io)) {
- lib3ds_file_free(file);
- iod->close();
- return(0);
- }
- lib3ds_io_free(io);
- iod->close();
- return(file);
-}
-
-QGL3dsSceneHandler::QGL3dsSceneHandler()
- : m_options(0)
-{
-}
-
-QGL3dsSceneHandler::~QGL3dsSceneHandler()
-{
- // nothing to do
-}
-
-void QGL3dsSceneHandler::decodeOptions(const QString &options)
-{
- static const char *validOptions[] = {
- "NativeIndices",
- "CorrectNormals",
- "CorrectAcute",
- "ForceSmooth",
- "ForceFaceted",
- "ShowWarnings"
- };
- static int optionKeys[] = {
- QGL::NativeIndices,
- QGL::CorrectNormals,
- QGL::CorrectAcute,
- QGL::ForceSmooth,
- QGL::ForceFaceted,
- QGL::ShowWarnings,
- -1
- };
-
- // format: "mesh=option mesh=option option option"
- // mesh: string name of a mesh in the file, with no spaces
- // standalone option applies to the whole file - all meshes
- // option: NativeIndices | CorrectNormals | CorrectAcute etc
- QStringList opList = options.split(QLatin1Char(' '), QString::SkipEmptyParts);
- for (int i = 0; i < opList.count(); ++i)
- {
- QString op = opList.at(i);
- QString mdl;
- if (op.contains(QLatin1Char('=')))
- {
- QStringList sl = op.split(QLatin1Char('='), QString::SkipEmptyParts);
- mdl = sl[0];
- op = sl[1];
- }
- int k = 0;
- for ( ; optionKeys[k] != -1; ++k)
- if (op == QLatin1String(validOptions[k]))
- break;
- if (optionKeys[k] != -1) // found
- {
- QGL::ModelOptions o = static_cast<QGL::ModelOptions>(optionKeys[k]);
- if (!mdl.isEmpty())
- setMeshOptions(o, mdl);
- else
- setOptions(o);
- }
- else
- {
- qWarning("Bad option: \"%s\" in %s", qPrintable(op),
- qPrintable(options));
- }
- }
-}
-
-QGLAbstractScene *QGL3dsSceneHandler::read()
-{
- Lib3dsFile *file = qgl3ds_lib3ds_file_load(device());
- Q_CHECK_PTR(file); // wtf?
-
- if (!file->nodes)
- {
- Lib3dsMesh *mesh;
- Lib3dsNode *node;
- for (mesh = file->meshes; mesh; mesh = mesh->next)
- {
- if (mesh->faces && mesh->points)
- {
- node = lib3ds_node_new_object();
- qstrcpy(node->name, mesh->name);
- node->parent_id = LIB3DS_NO_PARENT;
- lib3ds_file_insert_node(file, node);
- }
- }
- }
-
- lib3ds_file_eval(file, 0.0f);
-
- QGL3dsScene *scene = new QGL3dsScene(file, this);
- return scene;
-}
-
-QGLAbstractScene * QGL3dsSceneHandler::download()
-{
- qWarning() << "Network loading of 3ds files using this plugin is not implemented.";
- return NULL;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/3ds/qgl3dsscenehandler.h b/src/plugins/sceneformats/3ds/qgl3dsscenehandler.h
deleted file mode 100644
index a58e80f6..00000000
--- a/src/plugins/sceneformats/3ds/qgl3dsscenehandler.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSSCENEHANDLER_H
-#define QGL3DSSCENEHANDLER_H
-
-#include "qglsceneformatplugin.h"
-#include <QtCore/qmap.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QGL {
- enum ModelOption
- {
- NativeIndices = 0x01,
- CorrectNormals = 0x02,
- CorrectAcute = 0x04,
- ForceSmooth = 0x08,
- ForceFaceted = 0x10,
- ShowWarnings = 0x20
- };
- Q_DECLARE_FLAGS(ModelOptions, ModelOption);
-
- typedef QMap<QString, QGL::ModelOptions> MeshOptionMap;
-};
-
-class QGL3dsSceneHandler : public QGLSceneFormatHandler
-{
-public:
- QGL3dsSceneHandler();
- ~QGL3dsSceneHandler();
-
- QGLAbstractScene *read();
- QGLAbstractScene *download();
-
- void setOptions(QGL::ModelOptions options) { m_options |= options; }
- QGL::ModelOptions options() const { return m_options; }
-
- void setMeshOptions(QGL::ModelOptions options, const QString &meshName)
- {
- m_meshOptions[meshName] |= options;
- }
- QGL::ModelOptions meshOptions(const QString &meshName) const
- {
- if (m_meshOptions.contains(meshName))
- return m_meshOptions.value(meshName);
- return 0;
- }
- QGL::MeshOptionMap meshOptions() const { return m_meshOptions; }
- void decodeOptions(const QString &options);
-
-private:
- QGL::ModelOptions m_options;
- QGL::MeshOptionMap m_meshOptions;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGL::ModelOptions);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/sceneformats/assimp/README.txt b/src/plugins/sceneformats/assimp/README.txt
deleted file mode 100644
index cabf1bdd..00000000
--- 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/ailoaderiostream.cpp b/src/plugins/sceneformats/assimp/ailoaderiostream.cpp
deleted file mode 100644
index 7c8f1f97..00000000
--- a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "ailoaderiostream.h"
-
-#include <QtCore/qiodevice.h>
-
-#include <QtCore/qdebug.h>
-
-AiLoaderIOStream::AiLoaderIOStream(QIODevice *device)
- : m_device(device)
- , m_errorState(false)
-{
- Q_ASSERT(device);
-}
-
-AiLoaderIOStream::~AiLoaderIOStream()
-{
- // Nothing to do here
-}
-
-size_t AiLoaderIOStream::Read( void* pvBuffer, size_t pSize, size_t pCount)
-{
- qint64 result = m_device->read((char*)pvBuffer, pSize * pCount);
- size_t res = result;
- m_errorState = (result == -1);
- if (m_errorState)
- 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;
- qWarning("read mismatch requested size: %lu x count: %lu = %lu != %lu actuall read\n",
- pSizeP, pCountP, (pSizeP * pCountP), pRes);
- }
- return res;
-}
-
-size_t AiLoaderIOStream::Write( const void* pvBuffer, size_t pSize, size_t pCount)
-{
- qint64 result = m_device->write((char*)pvBuffer, pSize * pCount);
- m_errorState = (result == -1);
- if (m_errorState)
- qWarning("AI write error: %s\n", qPrintable(m_device->errorString()));
- return result;
-}
-
-aiReturn AiLoaderIOStream::Seek(size_t pOffset, aiOrigin pOrigin)
-{
- // cannot deal with sockets right now
- Q_ASSERT(!m_device->isSequential());
- switch (pOrigin)
- {
- case aiOrigin_SET:
- m_errorState = m_device->seek(pOffset);
- break;
- case aiOrigin_CUR:
- m_errorState = m_device->seek(m_device->pos() + pOffset);
- break;
- case aiOrigin_END:
- m_errorState = m_device->seek(m_device->size() + pOffset);
- break;
- default:
- Q_ASSERT(0);
- return(aiReturn_FAILURE);
- }
- if (m_errorState)
- return aiReturn_FAILURE;
- return aiReturn_SUCCESS;
-}
-
-size_t AiLoaderIOStream::Tell() const
-{
- return m_device->pos();
-}
-
-size_t AiLoaderIOStream::FileSize() const
-{
- return m_device->size();
-}
-
-void AiLoaderIOStream::Flush()
-{
- // do nothing
-}
diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.h b/src/plugins/sceneformats/assimp/ailoaderiostream.h
deleted file mode 100644
index b74d8c16..00000000
--- a/src/plugins/sceneformats/assimp/ailoaderiostream.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 AILOADERIOSTREAM_H
-#define AILOADERIOSTREAM_H
-
-#include <QtGlobal>
-#include "IOStream.h"
-#include "IOSystem.h"
-
-QT_BEGIN_NAMESPACE
-class QIODevice;
-QT_END_NAMESPACE
-
-class AiLoaderIOStream : public Assimp::IOStream
-{
-public:
- AiLoaderIOStream(QIODevice *device);
- ~AiLoaderIOStream();
- size_t Read( void* pvBuffer, size_t pSize, size_t pCount);
- size_t Write( const void* pvBuffer, size_t pSize, size_t pCount);
- aiReturn Seek( size_t pOffset, aiOrigin pOrigin);
- size_t Tell() const;
- size_t FileSize() const;
- void Flush();
- QIODevice *device() const { return m_device; }
-private:
- QIODevice *m_device;
- bool m_errorState;
-};
-
-#endif // AILOADERIOSTREAM_H
diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp b/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp
deleted file mode 100644
index d8978596..00000000
--- a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "ailoaderiosystem.h"
-#include "ailoaderiostream.h"
-#include "DefaultLogger.h"
-
-#include <QtCore/qfile.h>
-#include <QtCore/qdir.h>
-
-AiLoaderIOSystem::AiLoaderIOSystem(QIODevice *device, QUrl url)
- : m_device(device)
- , m_url(url)
-{
-}
-
-AiLoaderIOSystem::~AiLoaderIOSystem()
-{
- // we don't own m_device
- qDeleteAll(m_sub);
-}
-
-bool AiLoaderIOSystem::Exists(const char* path) const
-{
- Q_UNUSED(path);
-
- return m_device->isReadable();
-}
-
-char AiLoaderIOSystem::getOsSeparator() const
-{
- return QDir::separator().toLatin1();
-}
-
-/*!
- \internal
- Open the pFile with the pMode, where mode is given by "man fopen"
-*/
-Assimp::IOStream* AiLoaderIOSystem::Open(const char* pFile, const char* pMode)
-{
- // This is just the file already opened on the device
- if (m_url.toEncoded().endsWith(pFile))
- return new AiLoaderIOStream(m_device);
-
- // New relative file
- QUrl rel;
- rel.setScheme(m_url.scheme());
- rel.setPath(QLatin1String(pFile));
- QUrl url = m_url.resolved(rel);
-
- if (url.scheme() != QLatin1String("file"))
- {
- //network cases should already be opened by this stage - they
- //depend entirely on the download manager returning a QBuffer, so
- //cannot be handled as the simple "open file" case shown below.
- qWarning("Directly opening a network URL is not supported. Use scene handler code. (URL: %s).", qPrintable(url.scheme()));
- return 0;
- }
-
- char mode_str[4];
- qMemSet(mode_str, '\0', 4);
- int i = 0;
- for (const char *ptr = pMode; i < 4 && *ptr; ++ptr)
- {
- if (*ptr != 'b') // ignore the binary attribute
- mode_str[i++] = *ptr;
- }
- QIODevice::OpenMode mode = QIODevice::NotOpen;
- if (::strncmp("r", mode_str, 1) == 0)
- {
- mode = QIODevice::ReadOnly;
- }
- else if (::strncmp("r+", mode_str, 2) == 0)
- {
- mode = QIODevice::ReadWrite;
- }
- else if (::strncmp("w", mode_str, 1) == 0)
- {
- mode = QIODevice::WriteOnly | QIODevice::Truncate;
- }
- else if (::strncmp("w+", mode_str, 2) == 0)
- {
- mode = QIODevice::ReadWrite | QIODevice::Truncate;
- }
- else if (::strncmp("a", mode_str, 1) == 0)
- {
- mode = QIODevice::WriteOnly | QIODevice::Append;
- }
- else if (::strncmp("a+", mode_str, 2) == 0)
- {
- mode = QIODevice::ReadWrite | QIODevice::Append;
- }
- else
- {
- std::string err("Error: invalid mode flag:");
- err.append(mode_str).append(" when opening ").append(pFile);
- Assimp::DefaultLogger::get()->warn(err);
- return 0;
- }
-
- QFile *f = new QFile(url.toLocalFile());
- bool res = f->open(mode);
- if (!res)
- {
- std::string err("Error: could not open subsequent file:");
- err.append(pFile).append("--").append(f->errorString().toStdString());
- Assimp::DefaultLogger::get()->warn(err);
- delete f;
- return 0;
- }
- m_sub.append(f);
- AiLoaderIOStream *s = new AiLoaderIOStream(f);
- return s;
-}
-
-void AiLoaderIOSystem::Close(Assimp::IOStream* stream)
-{
- AiLoaderIOStream *s = static_cast<AiLoaderIOStream*>(stream);
- Q_ASSERT(s);
- s->device()->close();
- delete stream;
-}
diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.h b/src/plugins/sceneformats/assimp/ailoaderiosystem.h
deleted file mode 100644
index 00d2da6c..00000000
--- a/src/plugins/sceneformats/assimp/ailoaderiosystem.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 AILOADERIOSYSTEM_H
-#define AILOADERIOSYSTEM_H
-
-#include "IOSystem.h"
-
-#include <QtCore/qurl.h>
-
-QT_BEGIN_NAMESPACE
-class QIODevice;
-QT_END_NAMESPACE
-
-class IOStream;
-
-class AiLoaderIOSystem : public Assimp::IOSystem
-{
-public:
- AiLoaderIOSystem(QIODevice *device, QUrl url);
- ~AiLoaderIOSystem();
- virtual bool Exists( const char* path) const;
- virtual char getOsSeparator() const;
- virtual Assimp::IOStream* Open(const char* pFile, const char* pMode = "rb");
- virtual void Close(Assimp::IOStream* pFile);
-private:
- QIODevice *m_device;
- QList<QIODevice*> m_sub;
- QUrl m_url;
-};
-
-#endif // AILOADERIOSYSTEM_H
diff --git a/src/plugins/sceneformats/assimp/assimp.pro b/src/plugins/sceneformats/assimp/assimp.pro
deleted file mode 100644
index 142a62c7..00000000
--- a/src/plugins/sceneformats/assimp/assimp.pro
+++ /dev/null
@@ -1,62 +0,0 @@
-TARGET = qsceneai
-include(../../qpluginbase.pri)
-include(../../../../pkg.pri)
-HEADERS += qailoader.h \
- qaiscene.h \
- qaiscenehandler.h \
- qaimesh.h \
- ailoaderiostream.h \
- ailoaderiosystem.h
-SOURCES += main.cpp \
- qailoader.cpp \
- qaiscene.cpp \
- qaiscenehandler.cpp \
- qaimesh.cpp \
- ailoaderiostream.cpp \
- ailoaderiosystem.cpp
-
-# See the README in the root dir re this code
-package {
- macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- LIBS += -framework Qt3D -F../../../threed
- INCLUDEPATH += ../../../threed/Qt3D.framework/Versions/1/Headers
- } else {
- win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- LIBS += ..\\..\\..\\threed\\debug\\Qt3Dd.lib
- } else {
- LIBS += ..\\..\\..\\threed\\release\\Qt3D.lib
- }
- } else {
- LIBS += -L../../../threed -lQt3D
- }
- INCLUDEPATH += ../../../../include/Qt3D
- }
- target.path = $$QT3D_INSTALL_PLUGINS/sceneformats
- INSTALLS += target
-} else {
- CONFIG += qt3d
- DESTDIR = $$QT3D_INSTALL_PLUGINS/sceneformats
-}
-
-symbian {
- LIBS += -lQt3D$${QT_LIBINFIX}
- TARGET.UID3 = 0x20031E97
-}
-# 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/assimp/main.cpp b/src/plugins/sceneformats/assimp/main.cpp
deleted file mode 100644
index 6191c0a4..00000000
--- a/src/plugins/sceneformats/assimp/main.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsceneformatplugin.h"
-#include "qaiscenehandler.h"
-
-#include "assimp.hpp"
-
-#include <QtCore/qmap.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QAiScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-
-QStringList QAiScenePlugin::keys() const
-{
- static QMultiMap<QString, QString> mimetypes;
- if (mimetypes.size() == 0)
- {
- mimetypes.insertMulti("3ds", "application/x-3ds");
- mimetypes.insertMulti("3ds", "image/x-3ds");
- mimetypes.insertMulti("dae", "model/x3d+binary");
- mimetypes.insertMulti("dxf", "application/x-dxf");
- }
- QStringList result;
- Assimp::Importer importer;
- aiString extns;
- importer.GetExtensionList(extns);
- QString qextns = QString::fromUtf8(extns.data, extns.length);
- QStringList extnList = qextns.split(';');
- for (int i = 0; i < extnList.size(); ++i)
- {
- QString xt = extnList.at(i);
- xt = xt.simplified();
- if (xt.startsWith(QLatin1String("*.")))
- xt = xt.mid(2);
- result << xt;
- QMap<QString, QString>::const_iterator it = mimetypes.constFind(xt);
- for ( ; it != mimetypes.constEnd(); ++it)
- result << it.value();
- }
- return result;
-}
-
-QGLSceneFormatHandler *QAiScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-{
- Q_UNUSED(device);
- Q_UNUSED(url);
- Q_UNUSED(format);
- return new QAiSceneHandler;
-}
-
-Q_EXPORT_STATIC_PLUGIN(QAiScenePlugin)
-Q_EXPORT_PLUGIN2(qsceneai, QAiScenePlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/assimp/qailoader.cpp b/src/plugins/sceneformats/assimp/qailoader.cpp
deleted file mode 100644
index 280ca171..00000000
--- a/src/plugins/sceneformats/assimp/qailoader.cpp
+++ /dev/null
@@ -1,541 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qailoader.h"
-#include "qaiscenehandler.h"
-#include "qaiscene.h"
-#include "qaimesh.h"
-
-#include "qgeometrydata.h"
-#include "qgltwosidedmaterial.h"
-#include "qglmaterial.h"
-#include "qglmaterialcollection.h"
-#include "qglpainter.h"
-#include "qgltexture2d.h"
-#include "qglscenenode.h"
-#include "qlogicalvertex.h"
-
-#include "aiScene.h"
-#include "aiMaterial.h"
-#include "aiMesh.h"
-#include "DefaultLogger.h"
-
-#include <QtCore/qdir.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qfileinfo.h>
-
-QAiLoader::QAiLoader(const aiScene *scene, QAiSceneHandler* handler)
- : m_scene(scene)
- , m_root(0)
- , m_handler(handler)
- , m_hasTextures(false)
- , m_hasLitMaterials(false)
- , m_builder(new QGLMaterialCollection(m_root))
-{
- //nothing to do here
-}
-
-QAiLoader::~QAiLoader()
-{
- // nothing to do here - m_rootNode is taken ownership of by caller of
- // rootNode() method
-}
-
-static inline void assertOnePrimitiveType(aiMesh *mesh)
-{
-#ifndef QT_NO_DEBUG
- int k = 0; // count the number of bits set in the primitives
- unsigned int msk = 0x01;
- for (unsigned int p = mesh->mPrimitiveTypes; p; p >>= 1)
- if (p & msk)
- ++k;
- Q_ASSERT(k == 1); // Assimp SortByPType promises this
-#else
- Q_UNUSED(mesh);
-#endif
-}
-
-static inline bool qHasTextures(const QGLSceneNode *node)
-{
- QGLMaterial *mat = node->material();
- for (int i = 0; i < mat->textureLayerCount(); ++i)
- if (node->material()->texture(i))
- return true;
- return false;
-}
-
-void QAiLoader::loadMesh(aiMesh *mesh)
-{
- QString name = QString::fromUtf8(mesh->mName.data, mesh->mName.length);
- // qDebug() << "loadMesh" << name << "with" << mesh->mNumVertices << "vertices"
- // << "and" << mesh->mNumFaces << "faces";
-
- assertOnePrimitiveType(mesh);
-
- if (mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE)
- {
- m_builder.newSection();
- QGLSceneNode *node = m_builder.currentNode();
- node->setObjectName(name);
- QAiMesh m(mesh);
- m.build(m_builder, m_handler->showWarnings());
- m_meshes.append(node);
- if (qHasTextures(node))
- m_hasTextures = true;
- else
- m_hasLitMaterials = true;
- }
- else
- {
- // TODO: Implement other types in qaimesh.cpp
- if (m_handler->showWarnings())
- {
- QString error = QLatin1String("Bad primitive type in mesh %1 : %2");
- error = error.arg(name).arg(mesh->mPrimitiveTypes);
- Assimp::DefaultLogger::get()->warn(error.toStdString());
- }
- }
-
- if (m_handler->showWarnings())
- {
- if (!(m_handler->removeComponentFlags() & aiComponent_COLORS))
- {
- // TODO: Implement models with per vertex colors. Ok, the
- // vertex colors were wanted but are not supported yet.
- for (int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i)
- {
- if (mesh->HasVertexColors(i))
- {
- QString error = QLatin1String(
- "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.toStdString());
- break;
- }
- }
- }
- if (mesh->HasBones())
- {
- // TODO: Implement skeletal animation
- QString error = QLatin1String("Bones in mesh %1 not yet supported");
- error.arg(name);
- Assimp::DefaultLogger::get()->warn(error.toStdString());
- }
- 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.toStdString());
- }
- }
-}
-
-inline static QMatrix4x4 getNodeMatrix(aiNode *node)
-{
- QMatrix4x4 nodeMatrix;
- if (node->mTransformation.IsIdentity())
- return nodeMatrix;
- aiQuaternion rotation;
- aiVector3D position;
- aiVector3D scale;
- node->mTransformation.Decompose(scale, rotation, position);
- QVector3D qscale(scale.x,scale.y, scale.z);
- QVector3D qposition(position.x, position.y, position.z);
- QQuaternion qrotation(rotation.w, rotation.x, rotation.y, rotation.z);
- if (!qscale.isNull())
- nodeMatrix.scale(qscale);
- if (!qposition.isNull())
- nodeMatrix.translate(qposition);
- if (!qrotation.isNull())
- nodeMatrix.rotate(qrotation);
- return nodeMatrix;
-}
-
-void QAiLoader::loadNodes(aiNode *nodeList, QGLSceneNode *parentNode)
-{
- QMap<aiNode *, QGLSceneNode *>::const_iterator it = m_nodeMap.constFind(nodeList);
- QGLSceneNode *node = 0;
- if (it == m_nodeMap.constEnd()) // not found
- {
- node = new QGLSceneNode(parentNode);
- m_nodes.append(node);
- QString name = QString::fromUtf8(nodeList->mName.data, nodeList->mName.length);
- if (name.isEmpty())
- name = QString(QLatin1String("aiNode %1")).arg(m_nodes.size());
- node->setObjectName(name);
- QMatrix4x4 mat = getNodeMatrix(nodeList);
- if (!mat.isIdentity())
- node->setLocalTransform(mat);
- for (unsigned int i = 0; i < nodeList->mNumChildren; ++i)
- loadNodes(nodeList->mChildren[i], node);
- for (unsigned int i = 0; i < nodeList->mNumMeshes; ++i)
- {
- int n = nodeList->mMeshes[i];
- if (n < m_meshes.size())
- node->addNode(m_meshes.at(n));
- }
- }
- else
- {
- node = it.value();
- parentNode->addNode(node);
- }
-}
-
-/*!
- \internal
- Loads all the geometry, materials, and texture associations from the assigned
- file, and returns the root node of the resulting scene graph.
-
- The caller must take ownership of the root node returned, and delete it
- when its no longer required.
-*/
-QGLSceneNode *QAiLoader::loadMeshes()
-{
- Q_ASSERT(m_scene);
- for (unsigned int i = 0; i < m_scene->mNumMaterials; ++i)
- loadMaterial(m_scene->mMaterials[i]);
-
- // builds a naive scene heierarchy with all meshes under the root node
- for (unsigned int i = 0; i < m_scene->mNumMeshes; ++i)
- loadMesh(m_scene->mMeshes[i]);
-
- // fetch the naive scene heierarchy from the builder
- m_root = m_builder.finalizedSceneNode();
-
- QString name = m_handler->url().path();
- int pos = name.lastIndexOf("/");
- if (pos == -1)
- pos = name.lastIndexOf("\\");
- if (pos != -1)
- name = name.mid(pos+1);
- m_root->setObjectName(name);
-
- // if scene has a node heierarchy replace the naive heierarchy with that
- if (m_scene->mRootNode->mNumChildren > 0 && m_scene->mRootNode->mChildren)
- {
- m_root->removeNodes(m_root->children());
- loadNodes(m_scene->mRootNode, m_root);
- }
-
- if (m_hasTextures) // make textures the default
- {
- m_root->setEffect(QGL::LitModulateTexture2D);
- if (m_hasLitMaterials)
- {
- for (int i = 0; i < m_meshes.size(); ++i)
- if (!qHasTextures(m_meshes.at(i)))
- m_meshes.at(i)->setEffect(QGL::LitMaterial);
- }
- }
- else
- {
- m_root->setEffect(QGL::LitMaterial);
- }
-
- if (m_handler->showWarnings())
- {
- QString message = QLatin1String("AssetImporter loader %1 -- "
- "Mesh count: %2 -- Node count: %3 -- "
- "Material count: %4");
- 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.toStdString());
- }
-
-//#define DEBUG_ME
-#ifdef DEBUG_ME
- qDumpScene(m_root);
-
- QList<QGLSceneNode*> c = m_root->allChildren();
- QSet<quint64> debugged;
- for (int i = 0; i < c.size(); ++i)
- {
- if (c.at(i)->geometry().count() > 0)
- {
- QGeometryData g = c.at(i)->geometry();
- qDebug() << "geometry for:" << c.at(i) << "is:" << g.id();
- if (!debugged.contains(g.id()))
- {
- qDebug() << g;
- debugged.insert(g.id());
- }
- }
- }
-#endif
-
- return m_root;
-}
-
-/*!
- \internal
- Search for a resource based on the given \a path.
-
- If the URL for the currently loading mesh has a scheme other than
- "file" then a URL with the path relative to that URL is returned.
-
- If the URL for the currently loading mesh has a "file" scheme, then
- first a case-sensitive search is done of all of the current directory,
- and the :/ resource directory, and the directory of the current mesh
- file.
-
- If the file is not found in any of those locations then they are
- searched again case-insensitively. If the file is found, then a
- URL based on the absolute file path of the matching file is returned.
-
- Otherwise an empty string is returned.
-*/
-QUrl QAiLoader::ensureResource(const QString &path)
-{
- QUrl res;
- QUrl base = m_handler->url();
- if (base.scheme() == QLatin1String("file"))
- {
- res = base.resolved(path);
- //qDebug() << "ensureResource - base:" << base
- // << " -- path:" << path << "-- resolved:" << res;
- if (QFile::exists(res.path())) // shortcut common case
- return res;
- QStringList paths;
- paths << QLatin1String(".") << QLatin1String(":/"); // current directory and aliased/root resource file
- if (!base.isEmpty())
- {
- QFileInfo fi(base.path());
- paths.prepend(fi.absoluteDir().absolutePath());
- }
- bool caseInsensitive = false;
- do {
- QStringList::const_iterator it(paths.begin());
- for ( ; it != paths.end(); ++it)
- {
- QDir resDir(*it);
- QStringList fileList = resDir.entryList(QDir::Files);
- if (caseInsensitive)
- {
- QStringList::const_iterator fit(fileList.begin());
- for ( ; fit != fileList.end(); ++fit)
- {
- if (fit->toLower() == path.toLower())
- {
- res.setScheme(QLatin1String("file"));
- res.setPath(resDir.absoluteFilePath(*fit));
- break;
- }
- }
- }
- else
- {
- if (fileList.contains(path))
- {
- //return resDir.absoluteFilePath(path);
- res.setScheme(QLatin1String("file"));
- res.setPath(resDir.absoluteFilePath(path));
- break;
- }
- }
- }
- if (caseInsensitive)
- break;
- caseInsensitive = true;
- } while (true);
- }
- else
- {
- // non-file url
- res = base.resolved(path);
- }
- return res;
-}
-
-void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq)
-{
- int texCount;
- aiTextureType texType;
- if (m_handler->showWarnings())
- {
- // TODO: AssImp has a very rich set of texture related functionality
- // but until things in this list get implemented, all are just going
- // to get ignored, tho' they will generate a warning in verbose mode.
- // So for now, its just inside this conditional - move it out once
- // implementation of these items begins.
- static const char * typeNames[] = {
- "None",
- "Diffuse",
- "Specular",
- "Ambient",
- "Emissive",
- "Height",
- "Normals",
- "Shininess",
- "Opacity",
- "Displacement",
- "Lightmap",
- "Reflection",
- "Unknown",
- 0
- };
-
- for (unsigned int i = 0; i <= aiTextureType_UNKNOWN; ++i)
- {
- texType = static_cast<aiTextureType>(i);
- texCount = ma->GetTextureCount(texType);
- if (texCount && texType != aiTextureType_DIFFUSE)
- {
- QString error = QLatin1String("Unsupported texture type \"%1\" in material \"%2\".");
- error = error.arg(typeNames[i]).arg(mq->objectName());
- Assimp::DefaultLogger::get()->warn(error.toStdString());
- }
- }
- }
- // TODO: For now assume the only texture we care about is the diffuse one
- //
- texCount = ma->GetTextureCount(aiTextureType_DIFFUSE);
- if (texCount > 0)
- {
- if (texCount > 1 && m_handler->showWarnings())
- {
- QString error = QLatin1String("Multi-textures not supported: \"%1\" has %2");
- error.arg(mq->objectName()).arg(texCount);
- Assimp::DefaultLogger::get()->warn(error.toStdString());
- }
- else
- {
- aiString path;
- ma->Get(AI_MATKEY_TEXTURE_DIFFUSE(0), path);
- QString qpath = QString::fromUtf8(path.data, path.length);
- QUrl url = ensureResource(qpath);
- if (url.isEmpty())
- {
- if (m_handler->showWarnings())
- {
- QString error = QLatin1String("Could not load texture: %1 for material %2");
- error.arg(url.toString()).arg(mq->objectName());
- Assimp::DefaultLogger::get()->warn(error.toStdString());
- }
- }
- else
- {
- mq->setTextureUrl(url);
- }
- }
- }
-}
-
-/*!
- Load a material
-*/
-void QAiLoader::loadMaterial(aiMaterial *ma)
-{
- QGLMaterialCollection *palette = m_builder.palette();
- QGLMaterial *mq = new QGLMaterial;
- mq->setObjectName("___DEFAULT_NAME___");
-
- bool isTwoSided = false;
- bool isWireframe = false;
- struct aiColor4D clr;
- float shininess;
- float amplitude;
-
- aiReturn r;
-
- // In AssImp if the material is two sided then it means cull face
- // should be turned off: http://assimp.sourceforge.net/lib_html/materials.html
- r = ma->Get(AI_MATKEY_TWOSIDED, isTwoSided);
- if (r == aiReturn_SUCCESS && isTwoSided)
- mq->setProperty("isTwoSided", isTwoSided);
-
- aiString aName;
- r = ma->Get(AI_MATKEY_NAME, aName);
- if (r == aiReturn_SUCCESS && aName.length > 0)
- mq->setObjectName(QLatin1String(aName.data));
-
- r = ma->Get(AI_MATKEY_COLOR_AMBIENT, clr);
- if (r == aiReturn_SUCCESS)
- mq->setAmbientColor(QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a));
-
- r = ma->Get(AI_MATKEY_COLOR_DIFFUSE, clr);
- if (r == aiReturn_SUCCESS)
- mq->setDiffuseColor(QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a));
-
- r = ma->Get(AI_MATKEY_COLOR_SPECULAR, clr);
- if (r == aiReturn_SUCCESS)
- {
- QColor spec = QColor::fromRgbF(clr.r, clr.g, clr.b, clr.a);
- mq->setSpecularColor(spec);
-
- // By default the specular color is black - very dark.
- // If the specular color is bright be careful with shininess -
- // a shininess of 0 will blow everything out to full white. So in
- // the case of bad materials with this problem, set shiness low.
- mq->setShininess(64.0);
- }
-
- r = ma->Get(AI_MATKEY_SHININESS, shininess);
- if (r == aiReturn_SUCCESS)
- mq->setShininess(shininess);
-
- r = ma->Get(AI_MATKEY_SHININESS_STRENGTH, amplitude);
- if (r == aiReturn_SUCCESS)
- mq->setShininess(shininess * amplitude);
-
- r = ma->Get(AI_MATKEY_ENABLE_WIREFRAME, isWireframe);
- if (r == aiReturn_SUCCESS && isWireframe)
- mq->setProperty("isWireFrame", isWireframe);
-
- loadTextures(ma, mq);
-
- // INVARIANT: since we create the palette newly in this class, and this
- // function is the only place we add materials to this palette, the index
- // values (the positions in the palette generated by this call to addMaterial)
- // will exactly match the index values of the materials traversed in the
- // for loop in loadMeshes() - so therefore AI's index values and the ones in
- // the palette will be the same.
- //
- // executive summary: don't muck around with the palettte outside of this call
-
- int k = palette->addMaterial(mq);
-
- Q_UNUSED(k);
- //qDebug() << "loaded material" << k << mq;
-}
diff --git a/src/plugins/sceneformats/assimp/qailoader.h b/src/plugins/sceneformats/assimp/qailoader.h
deleted file mode 100644
index e7de0098..00000000
--- a/src/plugins/sceneformats/assimp/qailoader.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSLOADER_H
-#define QGL3DSLOADER_H
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qmap.h>
-
-#include "aiScene.h"
-
-#include "qglbuilder.h"
-
-class aiMaterial;
-
-QT_BEGIN_NAMESPACE
-
-class QAiMesh;
-class QGLSceneNode;
-class QAiSceneHandler;
-class QGLMaterial;
-class QAiScene;
-class QAiLoader
-{
-public:
- QAiLoader(const aiScene *scene, QAiSceneHandler* handler);
- ~QAiLoader();
- QGLSceneNode *loadMeshes();
-private:
- friend class QAiScene;
-
- void loadMesh(aiMesh *);
- void loadNodes(aiNode *, QGLSceneNode *);
- void loadMaterial(aiMaterial *);
- void loadTextures(aiMaterial *, QGLMaterial *);
- QUrl ensureResource(const QString &);
- void optimizeData();
- void optimizeNodes(QGLSceneNode *node = 0, QGLSceneNode *parent = 0);
- void countChildNodeReferences();
-
- const aiScene *m_scene;
- QGLSceneNode *m_root;
- QAiSceneHandler *m_handler;
- QList<QGLSceneNode *> m_nodes;
- QList<QGLMaterial *> m_materials;
- QList<QGLSceneNode *> m_meshes;
- QMap<aiNode *, QGLSceneNode *> m_nodeMap;
- QMap<QGLSceneNode *, int> m_refCounts;
- bool m_hasTextures;
- bool m_hasLitMaterials;
- QGLBuilder m_builder;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGL3DSLOADER_H
diff --git a/src/plugins/sceneformats/assimp/qaimesh.cpp b/src/plugins/sceneformats/assimp/qaimesh.cpp
deleted file mode 100644
index e7d4328e..00000000
--- a/src/plugins/sceneformats/assimp/qaimesh.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qaimesh.h"
-#include "qglscenenode.h"
-#include "qglmaterialcollection.h"
-#include "qglbuilder.h"
-
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qmath.h>
-
-#include "aiMesh.h"
-#include "DefaultLogger.h"
-
-QAiMesh::QAiMesh(aiMesh *mesh)
- : m_mesh(mesh)
-{
-}
-
-QAiMesh::~QAiMesh()
-{
-}
-
-static inline QVector2D qv2d(const aiVector3D &v)
-{
- return QVector2D(v.x, v.y);
-}
-
-static inline QVector2D qv2d_inv(const aiVector3D &v)
-{
- // invert the v coord because Qt is upside-down
- return QVector2D(v.x, (1.0 - v.y));
-}
-
-static inline QVector3D qv3d(const aiVector3D &v)
-{
- return QVector3D(v.x, v.y, v.z);
-}
-
-void QAiMesh::loadTriangles(QGLBuilder &builder)
-{
- QGeometryData data;
- for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i)
- data.appendVertex(qv3d(m_mesh->mVertices[i]));
- if (m_mesh->HasNormals())
- for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i)
- data.appendNormal(qv3d(m_mesh->mNormals[i]));
- int k = m_mesh->GetNumUVChannels();
- for (int t = 0; t < k; ++t)
- {
- 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))
- {
- 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));
- }
- else
- {
- for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i)
- data.appendTexCoord(qv2d(m_mesh->mTextureCoords[t][i]), static_cast<QGL::VertexAttribute>(QGL::TextureCoord0 + t));
- }
- }
-
- for (unsigned int i = 0; i < m_mesh->mNumFaces; ++i)
- {
- aiFace *face = &m_mesh->mFaces[i];
- data.appendIndices(face->mIndices[0], face->mIndices[1], face->mIndices[2]);
- }
-
- // raw triangle mode
- builder.addTriangles(data);
-}
-
-void QAiMesh::build(QGLBuilder &builder, bool showWarnings)
-{
- QGLSceneNode *node = builder.currentNode();
- QString name = node->objectName();
-
- if (!m_mesh->HasFaces() || !m_mesh->HasPositions())
- {
- if (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.toStdString());
- }
- return;
- }
-
- node->setMaterialIndex(m_mesh->mMaterialIndex);
- node->palette()->markMaterialAsUsed(m_mesh->mMaterialIndex);
-
- if (m_mesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE)
- loadTriangles(builder);
- else
- return; // TODO - lines, points, quads, polygons
-
- QGLMaterial * mat = node->palette()->material(m_mesh->mMaterialIndex);
- if (mat->property("isTwoSided").isValid() && mat->property("isTwoSided").toBool())
- node->setBackMaterialIndex(m_mesh->mMaterialIndex);
- if (mat->property("isWireFrame").isValid() && mat->property("isWireFrame").toBool())
- node->setDrawingMode(QGL::Lines);
-}
diff --git a/src/plugins/sceneformats/assimp/qaimesh.h b/src/plugins/sceneformats/assimp/qaimesh.h
deleted file mode 100644
index 23d352aa..00000000
--- a/src/plugins/sceneformats/assimp/qaimesh.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSMESH_H
-#define QGL3DSMESH_H
-
-#include "qaiscenehandler.h"
-#include "qgeometrydata.h"
-
-class aiMesh;
-
-QT_BEGIN_NAMESPACE
-
-class QGLMaterialCollection;
-class QGLSceneNode;
-class QGLBuilder;
-class QAiLoader;
-
-class QAiMesh
-{
-public:
- QAiMesh(aiMesh *mesh);
- virtual ~QAiMesh();
-
- void build(QGLBuilder &builder, bool showWarnings = false);
-private:
- void loadTriangles(QGLBuilder &builder);
-
- aiMesh *m_mesh;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGL3DSMESH_H
diff --git a/src/plugins/sceneformats/assimp/qaiscene.cpp b/src/plugins/sceneformats/assimp/qaiscene.cpp
deleted file mode 100644
index d3c48613..00000000
--- a/src/plugins/sceneformats/assimp/qaiscene.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qaiscene.h"
-#include "qaimesh.h"
-#include "qailoader.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QAiScene
- \brief The QAiScene class manages and contains an asset importer scene.
- The scene consists of a QGLSceneNode object which is the top-level node
- and references the geometry imported from a file.
-*/
-
-/*!
- \internal
- Construct a new QAiScene object using the data in the \a scene,
- and setting the given \a parent.
-
- The QAiScene object takes ownership of the \a file.
-*/
-QAiScene::QAiScene(const aiScene *scene, QAiSceneHandler *handler)
- : QGLAbstractScene(0)
-{
- Q_ASSERT(handler);
- Q_ASSERT(scene);
- QAiLoader loader(scene, handler);
- m_root = loader.loadMeshes();
- m_aiLoader = 0;
-}
-/*!
- \internal
- Construct a new QAiScene object and setting the given \a handler.
-
- Note that the scene which will be used to generate the QAiScene has
- not been added yet - this is used in the network case and requires
- a later call to the loadScene function to work correctly
-
- \sa loadScene()
-*/
-QAiScene::QAiScene(QAiSceneHandler *handler)
- : QGLAbstractScene(0)
-{
- Q_ASSERT(handler);
- //create a temporary loader and get a temporary root node for the scene.
- m_aiLoader = new QAiLoader(0, handler);
- m_root=m_aiLoader->m_builder.sceneNode();
-}
-
-/*!
- \reimp
- Destroy this QAiScene, recovering all resources.
-
- This method destroys the Lib3dsFile object the scene is based
- on by calling the appropriate lib3ds function.
-*/
-QAiScene::~QAiScene()
-{
- delete m_aiLoader;
-}
-
-/*!
- \internal
- \reimp
-*/
-QList<QObject *> QAiScene::objects() const
-{
- QList<QObject *> objs;
- if (!m_root)
- return objs;
- objs.append(m_root);
- QList<QGLSceneNode*> children = m_root->allChildren();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for ( ; it != children.constEnd(); ++it)
- objs.append(*it);
- return objs;
-}
-
-/*!
- \internal
- \reimp
-*/
-QGLSceneNode *QAiScene::mainNode() const
-{
- return m_root;
-}
-
-/*!
- \internal
- Returns the aiLoader associated with the scene (if any).
-*/
-QAiLoader * QAiScene::aiLoader() const
-{
- return m_aiLoader;
-}
-
-/*!
- \internal
- Load the new \a scene and swap the extant palette from the temporary roote
- node into the current root node.
-
- The QAiScene object takes ownership of the \a file.
-*/
-void QAiScene::loadScene(const aiScene *scene)
-{
- Q_ASSERT(scene);
-
- //Get the old material information
- QGLMaterialCollection *oldPalette= m_aiLoader->m_builder.palette();
- int oldIndex = m_root->materialIndex();
-
- //Reset the palette for the root node.
- QGLMaterialCollection *newPalette = new QGLMaterialCollection();
- m_aiLoader->m_builder.sceneNode()->setPalette(newPalette);
- m_aiLoader->m_scene = scene;
-
- //Commence loading of the mesh.
- m_root = m_aiLoader->loadMeshes(); //this won't actually change the root unless we've messed up.
- delete m_aiLoader;
- m_aiLoader = 0;
-
- //Swap out the materials palette
- int indexCount=0;
- int materialCount=0;
- QGLMaterial * currentMaterial = NULL;
- do {
- currentMaterial = oldPalette->removeMaterial(indexCount);
- if (currentMaterial) {
- materialCount = m_root->palette()->addMaterial(currentMaterial);
- indexCount++;
- }
- } while (currentMaterial);
- m_root->setMaterialIndex(materialCount-(indexCount-1)+oldIndex);
-
- //update picking nodes for the whole scene if needed
- if (pickable()) generatePickNodes();
-
- emit sceneUpdated();
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/assimp/qaiscene.h b/src/plugins/sceneformats/assimp/qaiscene.h
deleted file mode 100644
index f0c4a2b8..00000000
--- a/src/plugins/sceneformats/assimp/qaiscene.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSSCENE_H
-#define QGL3DSSCENE_H
-
-#include "qglabstractscene.h"
-#include "aiScene.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSceneNode;
-class QAiSceneHandler;
-class QAiLoader;
-
-class QAiScene : public QGLAbstractScene
-{
- Q_OBJECT
-public:
- explicit QAiScene(const aiScene *scene, QAiSceneHandler *handler);
- explicit QAiScene(QAiSceneHandler *handler);
-
- virtual ~QAiScene();
-
-
- //load scene with current handler.
- void loadScene(const aiScene *scene);
-
- QList<QObject *> objects() const;
- QGLSceneNode *mainNode() const;
-
- QAiLoader * aiLoader() const;
-
-protected:
- QGLSceneNode *m_root;
- QAiLoader *m_aiLoader;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp b/src/plugins/sceneformats/assimp/qaiscenehandler.cpp
deleted file mode 100644
index 5ae16c36..00000000
--- a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qaiscenehandler.h"
-#include "qaiscene.h"
-#include "ailoaderiosystem.h"
-
-#include "aiScene.h"
-#include "aiPostProcess.h"
-#include "DefaultLogger.h"
-
-#include "qdownloadmanager.h"
-
-#include <QtCore/qdir.h>
-#include <QtCore/qdebug.h>
-#include <QObject>
-#include <QBuffer>
-
-#define qAiPostProcessPreset ( \
- aiProcess_CalcTangentSpace | \
- aiProcess_GenSmoothNormals | \
- aiProcess_JoinIdenticalVertices | \
- aiProcess_ImproveCacheLocality | \
- aiProcess_LimitBoneWeights | \
- aiProcess_RemoveRedundantMaterials | \
- aiProcess_SplitLargeMeshes | \
- aiProcess_Triangulate | \
- aiProcess_GenUVCoords | \
- aiProcess_SortByPType | \
- aiProcess_FindDegenerates | \
- aiProcess_FindInvalidData )
-
-QT_BEGIN_NAMESPACE
-
-#ifdef _DEBUG
-void DumpScene(const aiScene* pScene);
-#endif
-
-QAiSceneHandler::QAiSceneHandler()
- : m_options(qAiPostProcessPreset)
- , m_showWarnings(false)
- , m_mayHaveLinesPoints(false)
- , m_meshSplitVertexLimit(2000)
- , m_meshSplitTriangleLimit(2000)
- , m_removeComponentFlags(0)
- , m_removeSortFlags(0)
-{
- // by default remove per vertex colors from the data - no-one uses that in
- // models - if they need it it can be turned on with UseVertexColors
- m_removeComponentFlags |= aiComponent_COLORS;
-
- // by default remove points and lines from the model, since these are usually
- // degenerate structures from bad modelling or bad import/export. if they
- // are needed it can be turned on with IncludeLinesPoints
- m_removeSortFlags |= aiPrimitiveType_POINT | aiPrimitiveType_LINE;
-}
-
-QAiSceneHandler::~QAiSceneHandler()
-{
- // nothing to do
-}
-
-void QAiSceneHandler::decodeOptions(const QString &options)
-{
- if (options.isEmpty())
- return;
-
- // See aiPostProcess.h for aiProcessPreset_TargetRealtime_Quality
- // - a useful default set of values - its exactly what we want but
- // wont compile with flags, so redefined with the above macro.
- // Also, allow the user to override some settings
- m_options = qAiPostProcessPreset;
-
- // Has to match the enum
- static const char *validOptions[] = {
- "NoOptions",
- "ShowWarnings",
- "CalculateNormals",
- "ForceFaceted",
- "ForceSmooth",
- "IncludeAllMaterials",
- "IncludeLinesPoints",
- "FixNormals",
- "DeDupMeshes",
- "Optimize",
- "FlipUVs",
- "FlipWinding",
- "UseVertexColors",
- "VertexSplitLimitx2",
- "TriangleSplitLimitx2",
- 0
- };
-
- QStringList opList = options.simplified().split(QLatin1Char(' '), QString::SkipEmptyParts);
-
- for (int i = 0; i < opList.count(); ++i)
- {
- QString op = opList.at(i);
- op = op.trimmed();
- int k = 0;
- for ( ; validOptions[k]; ++k)
- if (op == QString::fromLatin1(validOptions[k]))
- break;
- if (validOptions[k]) // found
- {
- Options o = static_cast<Options>(k);
- switch (o)
- {
- case NoOptions:
- break;
- case ShowWarnings:
- if (m_showWarnings)
- {
- m_importer.SetExtraVerbose(true);
- }
- else
- {
- m_showWarnings = true;
- m_options |= aiProcess_ValidateDataStructure;
- }
- break;
- case CalculateNormals:
- m_removeComponentFlags |= aiComponent_NORMALS;
- m_options |= aiProcess_GenSmoothNormals;
- m_options &= ~aiProcess_GenNormals;
- break;
- case ForceFaceted:
- m_removeComponentFlags |= aiComponent_NORMALS;
- m_options |= aiProcess_GenNormals;
- m_options &= ~aiProcess_GenSmoothNormals;
- m_options &= ~aiProcess_JoinIdenticalVertices;
- break;
- case ForceSmooth:
- Assimp::DefaultLogger::get()->warn("ForceSmooth is deprecated - ignoring (meshes now smooth by default)");
- break;
- case IncludeAllMaterials:
- m_options &= ~aiProcess_RemoveRedundantMaterials;
- break;
- case IncludeLinesPoints:
- m_removeSortFlags &= ~(aiPrimitiveType_LINE | aiPrimitiveType_POINT);
- m_mayHaveLinesPoints = true;
- // leave it with the FindDegenerates option turned on - we want zero
- // area triangles to display as proper GL lines or points
- break;
- case FixNormals:
- m_options |= aiProcess_FixInfacingNormals;
- break;
- case DeDupMeshes:
- m_options |= aiProcess_FindInstances;
- break;
- case Optimize:
- m_options |= aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes;
- break;
- case FlipUVs:
- m_options |= aiProcess_FlipUVs;
- break;
- case FlipWinding:
- m_options |= aiProcess_FlipWindingOrder;
- break;
- case UseVertexColors:
- m_removeComponentFlags &= ~aiComponent_COLORS;
- break;
- case VertexSplitLimitx2:
- m_meshSplitVertexLimit <<= 1;
- // repeating this in the option string more than once works...
- break;
- case TriangleSplitLimitx2:
- // ....and we're OK with that, just don't overdo it
- m_meshSplitTriangleLimit <<= 1;
- break;
- }
- }
- else
- {
- qWarning("Bad option: \"%s\" in %s", qPrintable(op),
- qPrintable(options));
- }
- }
-}
-
-QGLAbstractScene *QAiSceneHandler::read()
-{
- AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url());
- m_importer.SetIOHandler(ios);
-
- Assimp::Logger *log = 0;
- Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL;
- if (m_showWarnings)
- {
- severity = Assimp::Logger::VERBOSE;
- int streams = aiDefaultLogStream_FILE |
-#ifdef Q_CC_MSVC
- aiDefaultLogStream_DEBUGGER
-#else
- aiDefaultLogStream_STDERR
-#endif
- ;
- log = Assimp::DefaultLogger::create("AssimpLog.txt", severity, streams);
- }
-
- QString path;
- QUrl u = url();
- if (u.scheme() != QLatin1String("file"))
- {
- path = u.toEncoded();
- } else {
- path = u.toLocalFile();
- }
-
- if (m_removeComponentFlags)
- m_options |= aiProcess_RemoveComponent;
- else
- m_options &= ~aiProcess_RemoveComponent;
-
- m_importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, m_removeComponentFlags);
- m_importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, m_removeSortFlags);
- //m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, m_meshSplitVertexLimit);
- //m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, m_meshSplitTriangleLimit);
-
- // force this on, and provide no way to turn it off. Its set by the
- // aiProcessPreset_TargetRealtime_Quality option in the constructor.
- // Guarantees that all meshes only have one primitive type
- Q_ASSERT(m_options & aiProcess_SortByPType);
-
- // 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.toStdString(), m_options);
-
- if (!scene)
- {
- // Notes on import success flags - according to assimp doco if validation
- // is requested the flags AI_SCENE_FLAGS_VALIDATION_WARNING will be set
- // if there's a warning, and AI_SCENE_FLAGS_VALIDATED is set on success.
- // This does not happen. Also AI_SCENE_FLAGS_INCOMPLETE can be set on a
- // valid model, so checking for that is no use either. Best way to proceed
- // is that if ShowWarnings is turned on above, then any pertinent warnings
- // will be shown; and if a NULL result is returned here, then its a fatal
- // error and a message is shown here. If a non-NULL result is returned
- // just go ahead and try to load it.
- QString c = QDir::current().absolutePath();
- qWarning("Asset importer error: %s\n", m_importer.GetErrorString());
- if (log)
- qWarning("For details check log: %s/AssimpLog.txt\n", qPrintable(c));
- finalize();
- return 0;
- }
-#ifdef _DEBUG
- else {
- DumpScene(scene);
- }
-#endif
-
- QAiScene *qscene = new QAiScene(scene, this);
-
- Assimp::DefaultLogger::kill();
-
- finalize();
- return qscene;
-}
-
-QGLAbstractScene * QAiSceneHandler::download()
-{
- QUrl u = url();
-
- if (u.scheme() == QLatin1String("file")) {
- qWarning() << "Cannot download urls with FILE scheme. Use the read() method.";
- } else {
- if (m_removeComponentFlags)
- m_options |= aiProcess_RemoveComponent;
- else
- m_options &= ~aiProcess_RemoveComponent;
-
- m_importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, m_removeComponentFlags);
- m_importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, m_removeSortFlags);
- m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, m_meshSplitVertexLimit);
- m_importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, m_meshSplitTriangleLimit);
-
- // force this on, and provide no way to turn it off. Its set by the
- // aiProcessPreset_TargetRealtime_Quality option in the constructor.
- // Guarantees that all meshes only have one primitive type
- Q_ASSERT(m_options & aiProcess_SortByPType);
-
- setScene(new QAiScene(this));
- //m_scene = new QAiScene(this);
-
- //m_scene->begindownLoad(url());
-
- downloadScene();
- }
- return getScene();
-}
-
-void QAiSceneHandler::downloadComplete(QByteArray sceneData)
-{
- //Create i/o device to use for file reading.
- QBuffer sceneBuffer(&sceneData);
- sceneBuffer.open(QIODevice::ReadOnly);
- setDevice(&sceneBuffer);
-
- //Set i/o system to use non-file based device.
- AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url());
- m_importer.SetIOHandler(ios);
-
- QString path;
- path = url().toEncoded();
-
- Assimp::Logger *log = 0;
- Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL;
- if (m_showWarnings)
- {
- severity = Assimp::Logger::VERBOSE;
- int streams = aiDefaultLogStream_FILE |
-#ifdef Q_CC_MSVC
- aiDefaultLogStream_DEBUGGER
-#else
- aiDefaultLogStream_STDERR
-#endif
- ;
- log = Assimp::DefaultLogger::create("AssimpLog.txt", severity, streams);
- }
-
- const aiScene* scene = m_importer.ReadFile(path.toStdString(), m_options);
- if (!scene)
- {
- // Notes on import success flags - according to assimp doco if validation
- // is requested the flags AI_SCENE_FLAGS_VALIDATION_WARNING will be set
- // if there's a warning, and AI_SCENE_FLAGS_VALIDATED is set on success.
- // This does not happen. Also AI_SCENE_FLAGS_INCOMPLETE can be set on a
- // valid model, so checking for that is no use either. Best way to proceed
- // is that if ShowWarnings is turned on above, then any pertinent warnings
- // will be shown; and if a NULL result is returned here, then its a fatal
- // error and a message is shown here. If a non-NULL result is returned
- // just go ahead and try to load it.
- QString c = QDir::current().absolutePath();
- qWarning("Asset importer error: %s\n", m_importer.GetErrorString());
- if (log)
- qWarning("For details check log: %s/AssimpLog.txt\n", qPrintable(c));
- }
-#ifdef _DEBUG
- else {
- DumpScene(scene);
- //If we have reached this point everything has proceeded correctly,
- //load the scene.
- QAiScene *theScene = qobject_cast<QAiScene*>(getScene());
- theScene->loadScene(scene);
- }
-#endif
-
- Assimp::DefaultLogger::kill();
-
- finalize();
-}
-
-#ifdef _DEBUG
-void LogPrint(const char* pFormat, ...)
-{
- static char buff[1024];
- buff[0] = '\0';
- va_list args;
- va_start(args, pFormat);
- vsnprintf( buff, sizeof(buff) - 1, pFormat, args);
- qDebug() << buff;
-}
-
-void DumpAnimation(int i, const aiAnimation* pAnimation, const aiScene* pScene)
-{
- Q_UNUSED(pScene);
- LogPrint(" Animation %d",i);
- LogPrint(" name = '%s'",pAnimation->mName.data);
- LogPrint(" ticks = %f",pAnimation->mDuration);
- LogPrint(" ticks per sec = %f",pAnimation->mTicksPerSecond);
- for (unsigned int i=0; i<pAnimation->mNumChannels; ++i) {
- const aiNodeAnim* pNodeAnim = pAnimation->mChannels[i];
- LogPrint(" channel %d affects: '%s'", i, pNodeAnim->mNodeName.data);
- }
-}
-
-void DumpMesh(int i, const aiMesh* pMesh, const aiScene* pScene)
-{
- Q_UNUSED(pScene);
- LogPrint(" Mesh %d",i);
- LogPrint(" name = '%s'",pMesh->mName.data);
- LogPrint(" has bones: %s (%d)",pMesh->HasBones()?"YES":"no ",pMesh->mNumBones);
-}
-void DumpNodeRecursive(int level, const aiNode* pNode, const aiScene* pScene)
-{
- if (level > 100)
- level = 100;
- char Prefix[256];
- memset(Prefix,' ',level*2);
- Prefix[level*2] = '\0';
- LogPrint(" %sNode, name='%s', nMeshes=%d",Prefix,pNode->mName.data,pNode->mNumMeshes);
- for (unsigned int i=0; i<pNode->mNumChildren; ++i) {
- DumpNodeRecursive(level+1, pNode->mChildren[i], pScene);
- }
-}
-
-void DumpScene(const aiScene* pScene)
-{
- LogPrint("DumpScene(%p)",pScene);
- if (pScene) {
- LogPrint(" has animations: %s (%d)",pScene->HasAnimations()?"YES":"no ",pScene->mNumAnimations);
- LogPrint(" has meshes: %s (%d)",pScene->HasMeshes()?"YES":"no ",pScene->mNumMeshes);
- for (unsigned int i=0; i<pScene->mNumAnimations; ++i) {
- DumpAnimation(i,pScene->mAnimations[i],pScene);
- }
- for (unsigned int i=0; i<pScene->mNumMeshes; ++i) {
- DumpMesh(i,pScene->mMeshes[i],pScene);
- }
- DumpNodeRecursive(0,pScene->mRootNode,pScene);
- }
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.h b/src/plugins/sceneformats/assimp/qaiscenehandler.h
deleted file mode 100644
index b1738743..00000000
--- a/src/plugins/sceneformats/assimp/qaiscenehandler.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL3DSSCENEHANDLER_H
-#define QGL3DSSCENEHANDLER_H
-
-#include "qglsceneformatplugin.h"
-
-#include "aiPostProcess.h"
-#include "assimp.hpp"
-
-#include <QtCore/qurl.h>
-
-Q_DECLARE_FLAGS(aiPostProcessFlags, aiPostProcessSteps);
-Q_DECLARE_OPERATORS_FOR_FLAGS(aiPostProcessFlags);
-
-QT_BEGIN_NAMESPACE
-
-class QIODevice;
-
-class QAiSceneHandler : public QGLSceneFormatHandler
-{
- Q_OBJECT
-public:
- enum Options {
- NoOptions,
- ShowWarnings, // show any warnings while loading the file
- CalculateNormals, // replace normals from the file with smooth generated ones
- ForceFaceted, // generate non-smooth normals (implies CalculateNormals)
- ForceSmooth, // deprecated - retained only for backward compatibility
- IncludeAllMaterials, // include even redundant (unused) materials
- IncludeLinesPoints, // include even collapsed triangles (lines or points)
- FixNormals, // try to fix incorrect (in facing) normals
- DeDupMeshes, // replace copied meshes with refs to a single instance
- Optimize, // collapse meshes, nodes & scene heierarchies
- FlipUVs, // flips UV's on the y-axis (for upside-down textures)
- FlipWinding, // makes faces CW instead of CCW
- UseVertexColors, // use vertex colors that are in a model
- VertexSplitLimitx2, // double the vertex count which will split a large mesh
- TriangleSplitLimitx2 // double the triangle count which will split a large mesh
- };
-
- QAiSceneHandler();
- ~QAiSceneHandler();
-
- QGLAbstractScene *read();
- QGLAbstractScene *download();
-
- void decodeOptions(const QString &options);
-
- bool showWarnings() const { return m_showWarnings; }
- bool mayHaveLinesPoints() const { return m_mayHaveLinesPoints; }
-
- aiPostProcessFlags options() const { return m_options; }
- quint32 removeComponentFlags() const { return m_removeComponentFlags; }
- quint32 removeSortFlags() const { return m_removeSortFlags; }
-
-public slots:
- void downloadComplete(QByteArray sceneData);
-private:
- aiPostProcessFlags m_options;
- bool m_showWarnings;
- bool m_mayHaveLinesPoints;
- int m_meshSplitVertexLimit;
- int m_meshSplitTriangleLimit;
- Assimp::Importer m_importer;
- quint32 m_removeComponentFlags;
- quint32 m_removeSortFlags;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/sceneformats/bezier/bezier.pro b/src/plugins/sceneformats/bezier/bezier.pro
deleted file mode 100644
index 2b46207e..00000000
--- a/src/plugins/sceneformats/bezier/bezier.pro
+++ /dev/null
@@ -1,38 +0,0 @@
-TARGET = qscenebezier
-include(../../qpluginbase.pri)
-include(../../../../pkg.pri)
-
-HEADERS += qglbezierscene.h \
- qglbezierscenehandler.h
-SOURCES += main.cpp \
- qglbezierscene.cpp \
- qglbezierscenehandler.cpp
-
-# See the README in the root dir re this code
-package {
- macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- LIBS += -framework Qt3D -F../../../threed
- INCLUDEPATH += ../../../threed/Qt3D.framework/Versions/1/Headers
- } else {
- win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- LIBS += ..\\..\\..\\threed\\debug\\Qt3Dd.lib
- } else {
- LIBS += ..\\..\\..\\threed\\release\\Qt3D.lib
- }
- } else {
- LIBS += -L../../../threed -lQt3D$${QT_LIBINFIX}
- }
- INCLUDEPATH += ../../../../include/Qt3D
- }
- target.path = $$QT3D_INSTALL_PLUGINS/sceneformats
- INSTALLS += target
-} else {
- CONFIG += qt3d
- DESTDIR = $$QT3D_INSTALL_PLUGINS/sceneformats
-}
-symbian {
- LIBS += -lQt3D$${QT_LIBINFIX}
- TARGET.UID3 = 0x20031E98
-}
diff --git a/src/plugins/sceneformats/bezier/main.cpp b/src/plugins/sceneformats/bezier/main.cpp
deleted file mode 100644
index 5d503669..00000000
--- a/src/plugins/sceneformats/bezier/main.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsceneformatplugin.h"
-#include "qglbezierscenehandler.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLBezierScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-
-QStringList QGLBezierScenePlugin::keys() const
-{
- return QStringList() << QLatin1String("bezier") << QLatin1String("bez");
-}
-
-QGLSceneFormatHandler *QGLBezierScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-{
- Q_UNUSED(device);
- Q_UNUSED(url);
- Q_UNUSED(format);
- return new QGLBezierSceneHandler();
-}
-
-Q_EXPORT_STATIC_PLUGIN(QGLBezierScenePlugin)
-Q_EXPORT_PLUGIN2(qscenebezier, QGLBezierScenePlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.cpp b/src/plugins/sceneformats/bezier/qglbezierscene.cpp
deleted file mode 100644
index 9e93745b..00000000
--- a/src/plugins/sceneformats/bezier/qglbezierscene.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglbezierscene.h"
-#include "qglscenenode.h"
-
-QT_BEGIN_NAMESPACE
-
-QGLBezierScene::QGLBezierScene(QGLSceneNode *geometry, QObject *parent)
- : QGLAbstractScene(parent)
-{
- mainObject = geometry;
- mainObject->setObjectName(QLatin1String("mesh")); // No tr
- mainObject->setParent(this);
-}
-
-QGLBezierScene::~QGLBezierScene()
-{
-}
-
-QList<QObject *> QGLBezierScene::objects() const
-{
- QList<QObject *> objs;
- objs.append(mainObject);
- return objs;
-}
-
-QGLSceneNode *QGLBezierScene::mainNode() const
-{
- return mainObject;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.h b/src/plugins/sceneformats/bezier/qglbezierscene.h
deleted file mode 100644
index 17d64552..00000000
--- a/src/plugins/sceneformats/bezier/qglbezierscene.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLBEZIERSCENE_H
-#define QGLBEZIERSCENE_H
-
-#include "qglabstractscene.h"
-#include "qglbuilder.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLBezierScene : public QGLAbstractScene
-{
- Q_OBJECT
-public:
- explicit QGLBezierScene(QGLSceneNode *geometry, QObject *parent = 0);
- virtual ~QGLBezierScene();
-
- QList<QObject *> objects() const;
- QGLSceneNode *mainNode() const;
-
-private:
- QGLSceneNode *mainObject;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp b/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp
deleted file mode 100644
index cea212a6..00000000
--- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglbezierscenehandler.h"
-#include "qglbezierscene.h"
-#include "qglbezierpatches.h"
-#include "qvector3darray.h"
-#include <QtCore/qtextstream.h>
-
-QT_BEGIN_NAMESPACE
-
-QGLAbstractScene *QGLBezierSceneHandler::read()
-{
- QTextStream stream(device());
- QGLBezierPatches patches;
-
- // Read the number of patches from the first line.
- int patchCount;
- stream >> patchCount;
- stream.skipWhiteSpace();
- if (patchCount <= 0)
- return 0;
-
- // Read the patch indices.
- int depth = 0;
- QArray<int> indices;
- for (int patch = 0; patch < patchCount; ++patch) {
- bool eoln = false;
- for (int index = 0; index < 16; ++index) {
- int value;
- stream >> value;
- indices.append(value - 1);
-
- QChar sep;
- stream >> sep;
- if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r')) {
- eoln = true;
- break;
- }
- if (sep != QLatin1Char(','))
- return 0;
- }
- if (!eoln) {
- // Optional sub-division depth on the end.
- int value;
- stream >> value;
- if (value > depth)
- depth = value;
- }
- stream.skipWhiteSpace();
- }
-
- // Read the number of vertices.
- int vertexCount;
- stream >> vertexCount;
- stream.skipWhiteSpace();
- if (vertexCount <= 0)
- return 0;
-
- // Read the vertex values.
- QVector3DArray vertices;
- for (int vertex = 0; vertex < vertexCount; ++vertex) {
- bool eoln = false;
- qreal coords[3] = {0.0f, 0.0f, 0.0f};
- for (int index = 0; index < 3; ++index) {
- stream >> coords[index];
-
- QChar sep;
- stream >> sep;
- if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r')) {
- eoln = true;
- break;
- }
- if (sep != QLatin1Char(','))
- return 0;
- }
- vertices.append(coords[0], coords[1], coords[2]);
- if (!eoln) {
- // Optional normal on the end: read it but discard.
- for (int index = 0; index < 3; ++index) {
- stream >> coords[index];
-
- QChar sep;
- stream >> sep;
- if (sep == QLatin1Char('\n') || sep == QLatin1Char('\r'))
- break;
- if (sep != QLatin1Char(','))
- return 0;
- }
- }
- stream.skipWhiteSpace();
- }
-
- // Check for options at the end of the stream.
- if (!stream.atEnd()) {
- QChar ch;
- stream >> ch;
- if (ch == QLatin1Char('#')) {
- QString options = stream.readLine();
- if (options.contains(QLatin1String("teapot-adjust"))) {
- // Perform the "teapot adjustment" to convert the raw
- // teapot data into something more suitable for applications.
- // i.e., do the equivalent of the following transformation:
- // matrix.rotate(270.0f, 1.0f, 0.0f, 0.0f);
- // matrix.scale(0.5f, 0.5f, 0.5f);
- // matrix.translate(0.0f, 0.0f, -1.5f);
- for (int vertex = 0; vertex < vertexCount; ++vertex) {
- QVector3D vec = vertices[vertex];
- qreal x = vec.x();
- qreal y = vec.y();
- qreal z = vec.z();
- z -= 1.5f;
- x *= 0.5f;
- y *= 0.5f;
- z *= 0.5f;
- qreal y2 = z;
- qreal z2 = -y;
- y = y2;
- z = z2;
- vertices[vertex] = QVector3D(x, y, z);
- }
- }
- if (options.contains(QLatin1String("reverse-patches"))) {
- // Reverse the patch order to convert clockwise
- // patches into standard anti-clockwise patches.
- QArray<int> newIndices;
- for (int patch = 0; patch < patchCount; ++patch) {
- int temp[16];
- for (int index = 0; index < 16; ++index)
- temp[index] = indices[patch * 16 + index];
- for (int i = 0; i < 16; ++i)
- newIndices.append(temp[(i & 0x0C) + (3 - (i % 4))]);
- }
- indices = newIndices;
- }
- }
- }
-
- // Create the geometry node from the Bezier patch data.
- if (depth != 0)
- patches.setSubdivisionDepth(depth);
- QVector3DArray positions;
- for (int pindex = 0; pindex < indices.size(); ++pindex)
- positions += vertices[indices[pindex]];
- patches.setPositions(positions);
- QGLBuilder geometry;
- geometry << patches;
-
- // Create a scene with a single object containing the geometry.
- return new QGLBezierScene(geometry.finalizedSceneNode());
-}
-
-QGLAbstractScene *QGLBezierSceneHandler::download()
-{
- qWarning() << "Network loading is not supported for .bez files.";
- return NULL;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h b/src/plugins/sceneformats/bezier/qglbezierscenehandler.h
deleted file mode 100644
index ce093252..00000000
--- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLBEZIERSCENEHANDLER_H
-#define QGLBEZIERSCENEHANDLER_H
-
-#include "qglsceneformatplugin.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLBezierSceneHandler : public QGLSceneFormatHandler
-{
-public:
- QGLAbstractScene *read();
- QGLAbstractScene *download();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/sceneformats/obj/main.cpp b/src/plugins/sceneformats/obj/main.cpp
deleted file mode 100644
index 41f5645c..00000000
--- a/src/plugins/sceneformats/obj/main.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsceneformatplugin.h"
-#include "qglobjscenehandler.h"
-
-QT_BEGIN_NAMESPACE
-
-//! [1]
-class QGLObjScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-//! [1]
-
-//! [2]
-QStringList QGLObjScenePlugin::keys() const
-{
- return QStringList() << QLatin1String("obj") << QLatin1String("model/obj");
-}
-//! [2]
-
-//! [3]
-QGLSceneFormatHandler *QGLObjScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-{
- Q_UNUSED(device);
- Q_UNUSED(url);
- Q_UNUSED(format);
- return new QGLObjSceneHandler;
-}
-//! [3]
-
-//! [4]
-Q_EXPORT_STATIC_PLUGIN(QGLObjScenePlugin)
-Q_EXPORT_PLUGIN2(qsceneobj, QGLObjScenePlugin)
-//! [4]
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/obj/obj.pro b/src/plugins/sceneformats/obj/obj.pro
deleted file mode 100644
index a14a1ce7..00000000
--- a/src/plugins/sceneformats/obj/obj.pro
+++ /dev/null
@@ -1,37 +0,0 @@
-TARGET = qsceneobj
-include(../../qpluginbase.pri)
-include(../../../../pkg.pri)
-
-HEADERS += qglobjscene.h \
- qglobjscenehandler.h
-SOURCES += main.cpp \
- qglobjscene.cpp \
- qglobjscenehandler.cpp
-
-# See the README in the root dir re this code
-package {
- macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- LIBS += -framework Qt3D -F../../../threed
- INCLUDEPATH += ../../../threed/Qt3D.framework/Versions/1/Headers
- } else {
- win32 {
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- LIBS += ..\\..\\..\\threed\\debug\\Qt3Dd.lib
- } else {
- LIBS += ..\\..\\..\\threed\\release\\Qt3D.lib
- }
- } else {
- LIBS += -L../../../threed -lQt3D
- }
- INCLUDEPATH += ../../../../include/Qt3D
- }
- target.path = $$QT3D_INSTALL_PLUGINS/sceneformats
- INSTALLS += target
-} else {
- CONFIG += qt3d
- DESTDIR = $$QT3D_INSTALL_PLUGINS/sceneformats
-}
-
-target.path += $$QT3D_INSTALL_PLUGINS/sceneformats
-INSTALLS += target
diff --git a/src/plugins/sceneformats/obj/qglobjscene.cpp b/src/plugins/sceneformats/obj/qglobjscene.cpp
deleted file mode 100644
index ab5fb26e..00000000
--- a/src/plugins/sceneformats/obj/qglobjscene.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglobjscene.h"
-#include "qglbuilder.h"
-#include "qglscenenode.h"
-
-QT_BEGIN_NAMESPACE
-
-QGLObjScene::QGLObjScene(QGLSceneNode *defaultNode, QObject *parent)
- : QGLAbstractScene(parent)
- , mainObject(defaultNode)
-{
- defaultNode->setParent(this);
-}
-
-QGLObjScene::~QGLObjScene()
-{
-}
-
-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;
-}
-
-QGLSceneNode *QGLObjScene::mainNode() const
-{
- return mainObject;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/obj/qglobjscene.h b/src/plugins/sceneformats/obj/qglobjscene.h
deleted file mode 100644
index 832aac7e..00000000
--- a/src/plugins/sceneformats/obj/qglobjscene.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 04140f29..00000000
--- a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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()
- , palette(0)
- , 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 3c0d6a34..00000000
--- a/src/plugins/sceneformats/obj/qglobjscenehandler.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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);
-
- 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 97ec09a6..00000000
--- a/src/plugins/sceneformats/sceneformats.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = subdirs
-
-old_importer {
- SUBDIRS = bezier 3ds obj
-} else {
- SUBDIRS = bezier assimp
-}
diff --git a/src/private/private.pri b/src/private/private.pri
deleted file mode 100644
index b80e28a5..00000000
--- a/src/private/private.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
diff --git a/src/private/qfactoryloader_p.h b/src/private/qfactoryloader_p.h
deleted file mode 100644
index 34546ff0..00000000
--- a/src/private/qfactoryloader_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QFACTORYLOADER_P_H
-#define QFACTORYLOADER_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.
-//
-
-#include "QtCore/qobject.h"
-#include "QtCore/qstringlist.h"
-//#include "private/qlibrary_p.h"
-
-#ifndef QT_NO_LIBRARY
-
-QT_BEGIN_NAMESPACE
-
-class QFactoryLoaderPrivate;
-
-#ifdef Q_WS_X11
-class QLibraryPrivate;
-#endif
-
-class Q_CORE_EXPORT QFactoryLoader : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QFactoryLoader)
-
-public:
- QFactoryLoader(const char *iid,
- const QString &suffix = QString(),
- Qt::CaseSensitivity = Qt::CaseSensitive);
- ~QFactoryLoader();
-
- QStringList keys() const;
- QObject *instance(const QString &key) const;
-
-#ifdef Q_WS_X11
- QLibraryPrivate *library(const QString &key) const;
-#endif
-
- void update();
-
- static void refreshAll();
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_LIBRARY
-
-#endif // QFACTORYLOADER_P_H
diff --git a/src/private/qglextensions_p.h b/src/private/qglextensions_p.h
deleted file mode 100644
index 5a040035..00000000
--- a/src/private/qglextensions_p.h
+++ /dev/null
@@ -1,884 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGL_EXTENSIONS_P_H
-#define QGL_EXTENSIONS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the Qt OpenGL classes. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// extension prototypes
-#ifndef Q_WS_MAC
-# ifndef APIENTRYP
-# ifdef APIENTRY
-# define APIENTRYP APIENTRY *
-# else
-# define APIENTRY
-# define APIENTRYP *
-# endif
-# endif
-#else
-# define APIENTRY
-# define APIENTRYP *
-#endif
-
-#include <QtCore/qglobal.h>
-
-#ifndef GL_ARB_vertex_buffer_object
-typedef ptrdiff_t GLintptrARB;
-typedef ptrdiff_t GLsizeiptrARB;
-#endif
-
-#ifndef GL_VERSION_2_0
-typedef char GLchar;
-#endif
-
-// ARB_vertex_buffer_object
-typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint);
-typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *);
-typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *);
-typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum);
-typedef void (APIENTRY *_glBufferSubData) (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *);
-typedef void (APIENTRY *_glGetBufferSubData) (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *);
-typedef void (APIENTRY *_glGetBufferParameteriv) (GLenum, GLenum, GLint *);
-typedef GLvoid* (APIENTRY *_glMapBufferARB) (GLenum, GLenum);
-typedef GLboolean (APIENTRY *_glUnmapBufferARB) (GLenum);
-// We can call the buffer functions directly in OpenGL/ES 1.1 or higher,
-// but all other platforms need to resolve the extensions.
-#if defined(QT_OPENGL_ES)
-#if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1)
-#define QGL_RESOLVE_BUFFER_FUNCS 1
-#endif
-#else
-#define QGL_RESOLVE_BUFFER_FUNCS 1
-#endif
-
-// ARB_fragment_program
-typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *);
-typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint);
-typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *);
-typedef void (APIENTRY *_glGenProgramsARB) (GLsizei, GLuint *);
-typedef void (APIENTRY *_glProgramLocalParameter4fvARB) (GLenum, GLuint, const GLfloat *);
-
-// GLSL
-typedef GLuint (APIENTRY *_glCreateShader) (GLenum);
-typedef void (APIENTRY *_glShaderSource) (GLuint, GLsizei, const char **, const GLint *);
-typedef void (APIENTRY *_glShaderBinary) (GLint, const GLuint*, GLenum, const void*, GLint);
-typedef void (APIENTRY *_glCompileShader) (GLuint);
-typedef void (APIENTRY *_glDeleteShader) (GLuint);
-typedef GLboolean (APIENTRY *_glIsShader) (GLuint);
-
-typedef GLuint (APIENTRY *_glCreateProgram) ();
-typedef void (APIENTRY *_glAttachShader) (GLuint, GLuint);
-typedef void (APIENTRY *_glDetachShader) (GLuint, GLuint);
-typedef void (APIENTRY *_glLinkProgram) (GLuint);
-typedef void (APIENTRY *_glUseProgram) (GLuint);
-typedef void (APIENTRY *_glDeleteProgram) (GLuint);
-typedef GLboolean (APIENTRY *_glIsProgram) (GLuint);
-
-typedef void (APIENTRY *_glGetShaderInfoLog) (GLuint, GLsizei, GLsizei *, char *);
-typedef void (APIENTRY *_glGetShaderiv) (GLuint, GLenum, GLint *);
-typedef void (APIENTRY *_glGetShaderSource) (GLuint, GLsizei, GLsizei *, char *);
-typedef void (APIENTRY *_glGetProgramiv) (GLuint, GLenum, GLint *);
-typedef void (APIENTRY *_glGetProgramInfoLog) (GLuint, GLsizei, GLsizei *, char *);
-
-typedef GLuint (APIENTRY *_glGetUniformLocation) (GLuint, const char*);
-typedef void (APIENTRY *_glUniform4fv) (GLint, GLsizei, const GLfloat *);
-typedef void (APIENTRY *_glUniform3fv) (GLint, GLsizei, const GLfloat *);
-typedef void (APIENTRY *_glUniform2fv) (GLint, GLsizei, const GLfloat *);
-typedef void (APIENTRY *_glUniform1fv) (GLint, GLsizei, const GLfloat *);
-typedef void (APIENTRY *_glUniform1i) (GLint, GLint);
-typedef void (APIENTRY *_glUniform1iv) (GLint, GLsizei, const GLint *);
-typedef void (APIENTRY *_glUniformMatrix2fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix3fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix4fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix2x3fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix2x4fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix3x2fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix3x4fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix4x2fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-typedef void (APIENTRY *_glUniformMatrix4x3fv) (GLint, GLsizei, GLboolean, const GLfloat *);
-
-typedef void (APIENTRY *_glBindAttribLocation) (GLuint, GLuint, const char *);
-typedef GLint (APIENTRY *_glGetAttribLocation) (GLuint, const char *);
-typedef void (APIENTRY *_glVertexAttrib1fv) (GLuint, const GLfloat *);
-typedef void (APIENTRY *_glVertexAttrib2fv) (GLuint, const GLfloat *);
-typedef void (APIENTRY *_glVertexAttrib3fv) (GLuint, const GLfloat *);
-typedef void (APIENTRY *_glVertexAttrib4fv) (GLuint, const GLfloat *);
-typedef void (APIENTRY *_glVertexAttribPointer) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
-typedef void (APIENTRY *_glDisableVertexAttribArray) (GLuint);
-typedef void (APIENTRY *_glEnableVertexAttribArray) (GLuint);
-
-typedef void (APIENTRY *_glGetProgramBinaryOES) (GLuint, GLsizei, GLsizei *, GLenum *, void *);
-typedef void (APIENTRY *_glProgramBinaryOES) (GLuint, GLenum, const void *, GLint);
-
-
-typedef void (APIENTRY *_glMultiTexCoord4f) (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *_glActiveStencilFaceEXT) (GLenum );
-
-// Needed for GL2 engine:
-typedef void (APIENTRY *_glStencilOpSeparate) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (APIENTRY *_glActiveTexture) (GLenum);
-typedef void (APIENTRY *_glBlendColor) (GLclampf, GLclampf, GLclampf, GLclampf);
-
-
-// EXT_GL_framebuffer_object
-typedef GLboolean (APIENTRY *_glIsRenderbuffer) (GLuint renderbuffer);
-typedef void (APIENTRY *_glBindRenderbuffer) (GLenum target, GLuint renderbuffer);
-typedef void (APIENTRY *_glDeleteRenderbuffers) (GLsizei n, const GLuint *renderbuffers);
-typedef void (APIENTRY *_glGenRenderbuffers) (GLsizei n, GLuint *renderbuffers);
-typedef void (APIENTRY *_glRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRY *_glGetRenderbufferParameteriv) (GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (APIENTRY *_glIsFramebuffer) (GLuint framebuffer);
-typedef void (APIENTRY *_glBindFramebuffer) (GLenum target, GLuint framebuffer);
-typedef void (APIENTRY *_glDeleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
-typedef void (APIENTRY *_glGenFramebuffers) (GLsizei n, GLuint *framebuffers);
-typedef GLenum (APIENTRY *_glCheckFramebufferStatus) (GLenum target);
-typedef void (APIENTRY *_glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget,
- GLuint texture, GLint level);
-typedef void (APIENTRY *_glFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget,
- GLuint renderbuffer);
-typedef void (APIENTRY *_glGetFramebufferAttachmentParameteriv) (GLenum target, GLenum attachment, GLenum pname,
- GLint *params);
-typedef void (APIENTRY *_glGenerateMipmap) (GLenum target);
-
-// EXT_GL_framebuffer_blit
-typedef void (APIENTRY *_glBlitFramebufferEXT) (int srcX0, int srcY0, int srcX1, int srcY1,
- int dstX0, int dstY0, int dstX1, int dstY1,
- GLbitfield mask, GLenum filter);
-
-// EXT_GL_framebuffer_multisample
-typedef void (APIENTRY *_glRenderbufferStorageMultisampleEXT) (GLenum target, GLsizei samples,
- GLenum internalformat, GLsizei width, GLsizei height);
-
-// GL_EXT_geometry_shader4
-typedef void (APIENTRY *_glProgramParameteriEXT)(GLuint program, GLenum pname, GLint value);
-typedef void (APIENTRY *_glFramebufferTextureEXT)(GLenum target, GLenum attachment,
- GLuint texture, GLint level);
-typedef void (APIENTRY *_glFramebufferTextureLayerEXT)(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLint layer);
-typedef void (APIENTRY *_glFramebufferTextureFaceEXT)(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLenum face);
-
-// ARB_texture_compression
-typedef void (APIENTRY *_glCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei,
- GLsizei, GLint, GLsizei, const GLvoid *);
-
-QT_BEGIN_NAMESPACE
-
-struct QGLExtensionFuncs
-{
- QGLExtensionFuncs() {
-#if !defined(QT_OPENGL_ES_2)
- qt_glProgramStringARB = 0;
- qt_glBindProgramARB = 0;
- qt_glDeleteProgramsARB = 0;
- qt_glGenProgramsARB = 0;
- qt_glProgramLocalParameter4fvARB = 0;
-
- // GLSL
- qt_glCreateShader = 0;
- qt_glShaderSource = 0;
- qt_glShaderBinary = 0;
- qt_glCompileShader = 0;
- qt_glDeleteShader = 0;
- qt_glIsShader = 0;
-
- qt_glCreateProgram = 0;
- qt_glAttachShader = 0;
- qt_glDetachShader = 0;
- qt_glLinkProgram = 0;
- qt_glUseProgram = 0;
- qt_glDeleteProgram = 0;
- qt_glIsProgram = 0;
-
- qt_glGetShaderInfoLog = 0;
- qt_glGetShaderiv = 0;
- qt_glGetShaderSource = 0;
- qt_glGetProgramiv = 0;
- qt_glGetProgramInfoLog = 0;
-
- qt_glGetUniformLocation = 0;
- qt_glUniform4fv = 0;
- qt_glUniform3fv = 0;
- qt_glUniform2fv = 0;
- qt_glUniform1fv = 0;
- qt_glUniform1i = 0;
- qt_glUniform1iv = 0;
- qt_glUniformMatrix2fv = 0;
- qt_glUniformMatrix3fv = 0;
- qt_glUniformMatrix4fv = 0;
- qt_glUniformMatrix2x3fv = 0;
- qt_glUniformMatrix2x4fv = 0;
- qt_glUniformMatrix3x2fv = 0;
- qt_glUniformMatrix3x4fv = 0;
- qt_glUniformMatrix4x2fv = 0;
- qt_glUniformMatrix4x3fv = 0;
-
- qt_glBindAttribLocation = 0;
- qt_glGetAttribLocation = 0;
- qt_glVertexAttrib1fv = 0;
- qt_glVertexAttrib2fv = 0;
- qt_glVertexAttrib3fv = 0;
- qt_glVertexAttrib4fv = 0;
- qt_glVertexAttribPointer = 0;
- qt_glDisableVertexAttribArray = 0;
- qt_glEnableVertexAttribArray = 0;
-
- // Extras for GL2 engine:
- qt_glActiveTexture = 0;
- qt_glStencilOpSeparate = 0;
- qt_glBlendColor = 0;
-
- qt_glActiveStencilFaceEXT = 0;
- qt_glMultiTexCoord4f = 0;
-#else
- qt_glslResolved = false;
-
- qt_glGetProgramBinaryOES = 0;
- qt_glProgramBinaryOES = 0;
-#endif
-
- // FBOs
-#if !defined(QT_OPENGL_ES_2)
- qt_glIsRenderbuffer = 0;
- qt_glBindRenderbuffer = 0;
- qt_glDeleteRenderbuffers = 0;
- qt_glGenRenderbuffers = 0;
- qt_glRenderbufferStorage = 0;
- qt_glGetRenderbufferParameteriv = 0;
- qt_glIsFramebuffer = 0;
- qt_glBindFramebuffer = 0;
- qt_glDeleteFramebuffers = 0;
- qt_glGenFramebuffers = 0;
- qt_glCheckFramebufferStatus = 0;
- qt_glFramebufferTexture2D = 0;
- qt_glFramebufferRenderbuffer = 0;
- qt_glGetFramebufferAttachmentParameteriv = 0;
- qt_glGenerateMipmap = 0;
-#endif
- qt_glBlitFramebufferEXT = 0;
- qt_glRenderbufferStorageMultisampleEXT = 0;
-
- // Buffer objects:
-#if defined(QGL_RESOLVE_BUFFER_FUNCS)
- qt_glBindBuffer = 0;
- qt_glDeleteBuffers = 0;
- qt_glGenBuffers = 0;
- qt_glBufferData = 0;
- qt_glBufferSubData = 0;
- qt_glGetBufferSubData = 0;
- qt_glGetBufferParameteriv = 0;
-#endif
- qt_glMapBufferARB = 0;
- qt_glUnmapBufferARB = 0;
-
- qt_glProgramParameteriEXT = 0;
- qt_glFramebufferTextureEXT = 0;
- qt_glFramebufferTextureLayerEXT = 0;
- qt_glFramebufferTextureFaceEXT = 0;
-#if !defined(QT_OPENGL_ES)
- // Texture compression
- qt_glCompressedTexImage2DARB = 0;
-#endif
-
-#ifndef QT_NO_EGL
- // OES_EGL_image
- //qt_glEGLImageTargetTexture2DOES = 0;
- //qt_glEGLImageTargetRenderbufferStorageOES = 0;
-#endif
- }
-
-
-#if !defined(QT_OPENGL_ES_2)
- _glProgramStringARB qt_glProgramStringARB;
- _glBindProgramARB qt_glBindProgramARB;
- _glDeleteProgramsARB qt_glDeleteProgramsARB;
- _glGenProgramsARB qt_glGenProgramsARB;
- _glProgramLocalParameter4fvARB qt_glProgramLocalParameter4fvARB;
-
- // GLSL definitions
- _glCreateShader qt_glCreateShader;
- _glShaderSource qt_glShaderSource;
- _glShaderBinary qt_glShaderBinary;
- _glCompileShader qt_glCompileShader;
- _glDeleteShader qt_glDeleteShader;
- _glIsShader qt_glIsShader;
-
- _glCreateProgram qt_glCreateProgram;
- _glAttachShader qt_glAttachShader;
- _glDetachShader qt_glDetachShader;
- _glLinkProgram qt_glLinkProgram;
- _glUseProgram qt_glUseProgram;
- _glDeleteProgram qt_glDeleteProgram;
- _glIsProgram qt_glIsProgram;
-
- _glGetShaderInfoLog qt_glGetShaderInfoLog;
- _glGetShaderiv qt_glGetShaderiv;
- _glGetShaderSource qt_glGetShaderSource;
- _glGetProgramiv qt_glGetProgramiv;
- _glGetProgramInfoLog qt_glGetProgramInfoLog;
-
- _glGetUniformLocation qt_glGetUniformLocation;
- _glUniform4fv qt_glUniform4fv;
- _glUniform3fv qt_glUniform3fv;
- _glUniform2fv qt_glUniform2fv;
- _glUniform1fv qt_glUniform1fv;
- _glUniform1i qt_glUniform1i;
- _glUniform1iv qt_glUniform1iv;
- _glUniformMatrix2fv qt_glUniformMatrix2fv;
- _glUniformMatrix3fv qt_glUniformMatrix3fv;
- _glUniformMatrix4fv qt_glUniformMatrix4fv;
- _glUniformMatrix2x3fv qt_glUniformMatrix2x3fv;
- _glUniformMatrix2x4fv qt_glUniformMatrix2x4fv;
- _glUniformMatrix3x2fv qt_glUniformMatrix3x2fv;
- _glUniformMatrix3x4fv qt_glUniformMatrix3x4fv;
- _glUniformMatrix4x2fv qt_glUniformMatrix4x2fv;
- _glUniformMatrix4x3fv qt_glUniformMatrix4x3fv;
-
- _glBindAttribLocation qt_glBindAttribLocation;
- _glGetAttribLocation qt_glGetAttribLocation;
- _glVertexAttrib1fv qt_glVertexAttrib1fv;
- _glVertexAttrib2fv qt_glVertexAttrib2fv;
- _glVertexAttrib3fv qt_glVertexAttrib3fv;
- _glVertexAttrib4fv qt_glVertexAttrib4fv;
- _glVertexAttribPointer qt_glVertexAttribPointer;
- _glDisableVertexAttribArray qt_glDisableVertexAttribArray;
- _glEnableVertexAttribArray qt_glEnableVertexAttribArray;
-
-#else
- bool qt_glslResolved;
-
- _glGetProgramBinaryOES qt_glGetProgramBinaryOES;
- _glProgramBinaryOES qt_glProgramBinaryOES;
-#endif
-
- _glActiveStencilFaceEXT qt_glActiveStencilFaceEXT;
- _glMultiTexCoord4f qt_glMultiTexCoord4f;
-
-#if !defined(QT_OPENGL_ES_2)
- // Extras needed for GL2 engine:
- _glActiveTexture qt_glActiveTexture;
- _glStencilOpSeparate qt_glStencilOpSeparate;
- _glBlendColor qt_glBlendColor;
-
-#endif
-
- // FBOs
-#if !defined(QT_OPENGL_ES_2)
- _glIsRenderbuffer qt_glIsRenderbuffer;
- _glBindRenderbuffer qt_glBindRenderbuffer;
- _glDeleteRenderbuffers qt_glDeleteRenderbuffers;
- _glGenRenderbuffers qt_glGenRenderbuffers;
- _glRenderbufferStorage qt_glRenderbufferStorage;
- _glGetRenderbufferParameteriv qt_glGetRenderbufferParameteriv;
- _glIsFramebuffer qt_glIsFramebuffer;
- _glBindFramebuffer qt_glBindFramebuffer;
- _glDeleteFramebuffers qt_glDeleteFramebuffers;
- _glGenFramebuffers qt_glGenFramebuffers;
- _glCheckFramebufferStatus qt_glCheckFramebufferStatus;
- _glFramebufferTexture2D qt_glFramebufferTexture2D;
- _glFramebufferRenderbuffer qt_glFramebufferRenderbuffer;
- _glGetFramebufferAttachmentParameteriv qt_glGetFramebufferAttachmentParameteriv;
- _glGenerateMipmap qt_glGenerateMipmap;
-#endif
- _glBlitFramebufferEXT qt_glBlitFramebufferEXT;
- _glRenderbufferStorageMultisampleEXT qt_glRenderbufferStorageMultisampleEXT;
-
- // Buffer objects
-#if defined(QGL_RESOLVE_BUFFER_FUNCS)
- _glBindBuffer qt_glBindBuffer;
- _glDeleteBuffers qt_glDeleteBuffers;
- _glGenBuffers qt_glGenBuffers;
- _glBufferData qt_glBufferData;
- _glBufferSubData qt_glBufferSubData;
- _glGetBufferSubData qt_glGetBufferSubData;
- _glGetBufferParameteriv qt_glGetBufferParameteriv;
-#endif
- _glMapBufferARB qt_glMapBufferARB;
- _glUnmapBufferARB qt_glUnmapBufferARB;
-
- // Geometry shaders...
- _glProgramParameteriEXT qt_glProgramParameteriEXT;
- _glFramebufferTextureEXT qt_glFramebufferTextureEXT;
- _glFramebufferTextureLayerEXT qt_glFramebufferTextureLayerEXT;
- _glFramebufferTextureFaceEXT qt_glFramebufferTextureFaceEXT;
-#if !defined(QT_OPENGL_ES)
- // Texture compression
- _glCompressedTexImage2DARB qt_glCompressedTexImage2DARB;
-#endif
-
-#ifndef QT_NO_EGL
- // OES_EGL_image
- //_glEGLImageTargetTexture2DOES qt_glEGLImageTargetTexture2DOES;
- //_glEGLImageTargetRenderbufferStorageOES qt_glEGLImageTargetRenderbufferStorageOES;
-#endif
-};
-
-
-// OpenGL constants
-
-#ifndef GL_ARRAY_BUFFER
-#define GL_ARRAY_BUFFER 0x8892
-#endif
-
-#ifndef GL_STATIC_DRAW
-#define GL_STATIC_DRAW 0x88E4
-#endif
-
-/* NV_texture_rectangle */
-#ifndef GL_NV_texture_rectangle
-#define GL_TEXTURE_RECTANGLE_NV 0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
-#endif
-
-#ifndef GL_BGRA
-#define GL_BGRA 0x80E1
-#endif
-
-#ifndef GL_RGB16
-#define GL_RGB16 0x8054
-#endif
-
-#ifndef GL_UNSIGNED_SHORT_5_6_5
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#endif
-
-#ifndef GL_UNSIGNED_INT_8_8_8_8_REV
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#endif
-
-#ifndef GL_MULTISAMPLE
-#define GL_MULTISAMPLE 0x809D
-#endif
-
-#ifndef GL_CLAMP_TO_EDGE
-#define GL_CLAMP_TO_EDGE 0x812F
-#endif
-
-#ifndef GL_IBM_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_IBM 0x8370
-#endif
-
-#ifndef GL_SGIS_generate_mipmap
-#define GL_GENERATE_MIPMAP_SGIS 0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
-#endif
-
-// ARB_fragment_program extension protos
-#ifndef GL_FRAGMENT_PROGRAM_ARB
-#define GL_FRAGMENT_PROGRAM_ARB 0x8804
-#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
-#endif
-
-#ifndef GL_PIXEL_UNPACK_BUFFER_ARB
-#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
-#endif
-
-#ifndef GL_WRITE_ONLY_ARB
-#define GL_WRITE_ONLY_ARB 0x88B9
-#endif
-
-#ifndef GL_STREAM_DRAW_ARB
-#define GL_STREAM_DRAW_ARB 0x88E0
-#endif
-
-// Stencil wrap and two-side defines
-#ifndef GL_STENCIL_TEST_TWO_SIDE_EXT
-#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
-#endif
-#ifndef GL_INCR_WRAP_EXT
-#define GL_INCR_WRAP_EXT 0x8507
-#endif
-#ifndef GL_DECR_WRAP_EXT
-#define GL_DECR_WRAP_EXT 0x8508
-#endif
-
-#ifndef GL_TEXTURE0
-#define GL_TEXTURE0 0x84C0
-#endif
-
-#ifndef GL_TEXTURE1
-#define GL_TEXTURE1 0x84C1
-#endif
-
-#ifndef GL_DEPTH_COMPONENT16
-#define GL_DEPTH_COMPONENT16 0x81A5
-#endif
-
-#ifndef GL_DEPTH_COMPONENT24_OES
-#define GL_DEPTH_COMPONENT24_OES 0x81A6
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
-#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
-#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
-#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
-#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
-#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
-#define GL_FRAMEBUFFER_EXT 0x8D40
-#define GL_RENDERBUFFER_EXT 0x8D41
-#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
-#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
-#define GL_STENCIL_INDEX_EXT 0x8D45
-#define GL_STENCIL_INDEX1_EXT 0x8D46
-#define GL_STENCIL_INDEX4_EXT 0x8D47
-#define GL_STENCIL_INDEX8_EXT 0x8D48
-#define GL_STENCIL_INDEX16_EXT 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
-#endif
-
-// GL_EXT_framebuffer_blit
-#ifndef GL_READ_FRAMEBUFFER_EXT
-#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
-#endif
-
-// GL_EXT_framebuffer_multisample
-#ifndef GL_RENDERBUFFER_SAMPLES_EXT
-#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
-#endif
-
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#endif
-
-#ifndef GL_MAX_SAMPLES_EXT
-#define GL_MAX_SAMPLES_EXT 0x8D57
-#endif
-
-#ifndef GL_DRAW_FRAMEBUFFER_EXT
-#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
-#endif
-
-#ifndef GL_EXT_packed_depth_stencil
-#define GL_DEPTH_STENCIL_EXT 0x84F9
-#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
-#define GL_DEPTH24_STENCIL8_EXT 0x88F0
-#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
-#endif
-
-// ### hm. should be part of the GL 1.2 spec..
-#ifndef GL_CLAMP_TO_EDGE
-#define GL_CLAMP_TO_EDGE 0x812F
-#endif
-
-#ifndef GL_VERSION_1_2
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#endif
-
-#ifndef GL_VERSION_1_4
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-#endif
-
-#ifndef GL_VERSION_1_5
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_STREAM_COPY 0x88E2
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STATIC_COPY 0x88E6
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_DYNAMIC_COPY 0x88EA
-#endif
-
-#ifndef GL_VERSION_2_0
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_LINK_STATUS 0x8B82
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#endif
-
-// Geometry shader defines
-#ifndef GL_GEOMETRY_SHADER_EXT
-# define GL_GEOMETRY_SHADER_EXT 0x8DD9
-# define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA
-# define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB
-# define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC
-# define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
-# define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD
-# define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE
-# define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B
-# define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
-# define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
-# define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
-# define GL_LINES_ADJACENCY_EXT 0xA
-# define GL_LINE_STRIP_ADJACENCY_EXT 0xB
-# define GL_TRIANGLES_ADJACENCY_EXT 0xC
-# define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD
-# define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
-# define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9
-# define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
-# define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
-# define GL_PROGRAM_POINT_SIZE_EXT 0x8642
-#endif
-
-#if !defined(QT_OPENGL_ES_2)
-#define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB
-#define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB
-#define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB
-#define glGenProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glGenProgramsARB
-#define glProgramLocalParameter4fvARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramLocalParameter4fvARB
-
-#define glActiveStencilFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glActiveStencilFaceEXT
-
-#define glMultiTexCoord4f QGLContextPrivate::extensionFuncs(ctx).qt_glMultiTexCoord4f
-
-#define glActiveTexture QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture
-#endif // !defined(QT_OPENGL_ES_2)
-
-
-// FBOs
-#if !defined(QT_OPENGL_ES_2)
-#define glIsRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsRenderbuffer
-#define glBindRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer
-#define glDeleteRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers
-#define glGenRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers
-#define glRenderbufferStorage QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage
-#define glGetRenderbufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv
-#define glIsFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsFramebuffer
-#define glBindFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer
-#define glDeleteFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers
-#define glGenFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenFramebuffers
-#define glCheckFramebufferStatus QGLContextPrivate::extensionFuncs(ctx).qt_glCheckFramebufferStatus
-#define glFramebufferTexture2D QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D
-#define glFramebufferRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer
-#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetFramebufferAttachmentParameteriv
-#define glGenerateMipmap QGLContextPrivate::extensionFuncs(ctx).qt_glGenerateMipmap
-#endif // QT_OPENGL_ES_2
-#define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT
-#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT
-
-
-// Buffer objects
-#if defined(QGL_RESOLVE_BUFFER_FUNCS)
-#define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer
-#define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers
-#define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers
-#define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData
-#define glBufferSubData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferSubData
-#define glGetBufferSubData QGLContextPrivate::extensionFuncs(ctx).qt_glGetBufferSubData
-#define glGetBufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetBufferParameteriv
-#endif
-#define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB
-#define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB
-
-
-// GLSL
-#if !defined(QT_OPENGL_ES_2)
-
-#define glCreateShader QGLContextPrivate::extensionFuncs(ctx).qt_glCreateShader
-#define glShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glShaderSource
-#define glShaderBinary QGLContextPrivate::extensionFuncs(ctx).qt_glShaderBinary
-#define glCompileShader QGLContextPrivate::extensionFuncs(ctx).qt_glCompileShader
-#define glDeleteShader QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteShader
-#define glIsShader QGLContextPrivate::extensionFuncs(ctx).qt_glIsShader
-
-#define glCreateProgram QGLContextPrivate::extensionFuncs(ctx).qt_glCreateProgram
-#define glAttachShader QGLContextPrivate::extensionFuncs(ctx).qt_glAttachShader
-#define glDetachShader QGLContextPrivate::extensionFuncs(ctx).qt_glDetachShader
-#define glLinkProgram QGLContextPrivate::extensionFuncs(ctx).qt_glLinkProgram
-#define glUseProgram QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram
-#define glDeleteProgram QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgram
-#define glIsProgram QGLContextPrivate::extensionFuncs(ctx).qt_glIsProgram
-
-#define glGetShaderInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderInfoLog
-#define glGetShaderiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderiv
-#define glGetShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderSource
-#define glGetProgramiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramiv
-#define glGetProgramInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramInfoLog
-
-#define glGetUniformLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetUniformLocation
-#define glUniform4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform4fv
-#define glUniform3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform3fv
-#define glUniform2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform2fv
-#define glUniform1fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1fv
-#define glUniform1i QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1i
-#define glUniform1iv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1iv
-#define glUniformMatrix2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2fv
-#define glUniformMatrix3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3fv
-#define glUniformMatrix4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4fv
-#define glUniformMatrix2x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x3fv
-#define glUniformMatrix2x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x4fv
-#define glUniformMatrix3x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x2fv
-#define glUniformMatrix3x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x4fv
-#define glUniformMatrix4x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x2fv
-#define glUniformMatrix4x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x3fv
-
-#define glBindAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glBindAttribLocation
-#define glGetAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetAttribLocation
-#define glVertexAttrib1fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib1fv
-#define glVertexAttrib2fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib2fv
-#define glVertexAttrib3fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv
-#define glVertexAttrib4fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib4fv
-#define glVertexAttribPointer QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer
-#define glDisableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray
-#define glEnableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glEnableVertexAttribArray
-
-#else // QT_OPENGL_ES_2
-
-#define glGetProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramBinaryOES
-#define glProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glProgramBinaryOES
-
-#endif // QT_OPENGL_ES_2
-
-
-#if !defined(QT_OPENGL_ES_2)
-#define glStencilOpSeparate QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate
-#define glBlendColor QGLContextPrivate::extensionFuncs(ctx).qt_glBlendColor
-#endif
-
-#if defined(QT_OPENGL_ES_2)
-#define glClearDepth glClearDepthf
-#endif
-
-#define glProgramParameteriEXT QGLContextPrivate::extensionFuncs(ctx).qt_glProgramParameteriEXT
-#define glFramebufferTextureEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureEXT
-#define glFramebufferTextureLayerEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureLayerEXT
-#define glFramebufferTextureFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureFaceEXT
-
-#if !defined(QT_OPENGL_ES)
-#define glCompressedTexImage2D QGLContextPrivate::extensionFuncs(ctx).qt_glCompressedTexImage2DARB
-#endif
-
-#ifndef QT_NO_EGL
-// OES_EGL_image
-#define glEGLImageTargetTexture2DOES QGLContextPrivate::extensionFuncs(ctx).qt_glEGLImageTargetTexture2DOES
-#define glEGLImageTargetRenderbufferStorageOES QGLContextPrivate::extensionFuncs(ctx).qt_glEGLImageTargetRenderbufferStorageOES
-#endif
-
-extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx);
-bool qt_resolve_buffer_extensions(QGLContext *ctx);
-
-bool qt_resolve_version_1_3_functions(QGLContext *ctx);
-bool qt_resolve_version_2_0_functions(QGLContext *ctx);
-bool qt_resolve_stencil_face_extension(QGLContext *ctx);
-bool qt_resolve_frag_program_extensions(QGLContext *ctx);
-
-bool qt_resolve_glsl_extensions(QGLContext *ctx);
-
-#ifndef QT_NO_EGL
-Q_OPENGL_EXPORT bool qt_resolve_eglimage_gl_extensions(QGLContext *ctx);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QGL_EXTENSIONS_P_H
diff --git a/src/quick3d/qdeclarativeeffect.cpp b/src/quick3d/qdeclarativeeffect.cpp
deleted file mode 100644
index 77992958..00000000
--- a/src/quick3d/qdeclarativeeffect.cpp
+++ /dev/null
@@ -1,479 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qdeclarativeeffect.h"
-
-#include "qglpainter.h"
-#include "qglmaterial.h"
-
-#include <QNetworkRequest>
-#include <QNetworkReply>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <qdeclarativeinfo.h>
-#include "qglscenenode.h"
-
-/*!
- \qmlclass Effect QDeclarativeEffect
- \brief The Effect item defines simple effects within the QML/3D environment. Examples
- of such effects include textures, simple material and lighting effects, and so on.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \section1 Defining an Effect
-
- Effects can be defined within QML using the normal syntax for creating any QML/3d object. To create a
- default effect with no extra information, for example, we can simply using the following:
-
- \code
- Effect {}
- \endcode
-
- More complex effects use the usual QML syntax for accessing and updating properties. In order to specify
- a texture, for example, the following could be used:
-
- \code
- Effect {
- id: myTextureEffect
- texture: "texture.png"
- }
- \endcode
-*/
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEffectPrivate
-{
-public:
- QDeclarativeEffectPrivate()
- : color(255, 255, 255, 255),
- useLighting(true),
- decal(false),
- blending(false),
- palette(0),
- materialIndex(-1),
- progress(0.0)
- {
- }
-
- ~QDeclarativeEffectPrivate()
- {
- delete palette;
- }
-
- QColor color;
- bool useLighting;
- bool decal;
- bool blending;
- QGLMaterialCollection *palette;
- int materialIndex;
- qreal progress;
- inline void ensureMaterial() {
- if (!palette)
- {
- palette = new QGLMaterialCollection();
- }
- if (materialIndex == -1)
- {
- materialIndex = palette->addMaterial(new QGLMaterial(palette));
- palette->material(materialIndex)->setColor(color);
- }
- // TODO: decal & blending
- }
-};
-
-/*!
- \internal
- Constructs the Effect object with \a parent as its parent.
-*/
-QDeclarativeEffect::QDeclarativeEffect(QObject *parent)
- : QObject(parent)
-{
- d = new QDeclarativeEffectPrivate;
-}
-
-/*!
- \internal
- Destroy the \l Effect object and delete any unneeded data.
-*/
-QDeclarativeEffect::~QDeclarativeEffect()
-{
- delete d;
-}
-
-/*!
- \qmlproperty color Effect::color
-
- The color of the object for simple non-texture effects.
- The default value for this property is white.
-*/
-
-QColor QDeclarativeEffect::color() const
-{
- return d->color;
-}
-
-void QDeclarativeEffect::setColor(const QColor& value)
-{
- d->color = value;
- d->ensureMaterial();
- material()->setColor(value);
- emit effectChanged();
-}
-
-/*!
- \qmlproperty bool Effect::useLighting
-
- The lighting control parameter; true if this effect should
- use lighting or false if this effect should use flat colors and
- textures.
-
- The default value for this property is true.
-*/
-bool QDeclarativeEffect::useLighting() const
-{
- return d->useLighting;
-}
-
-void QDeclarativeEffect::setUseLighting(bool value)
-{
- d->useLighting = value;
- emit effectChanged();
-}
-
-/*!
- \qmlproperty bool Effect::decal
-
- This property should be set to true if the \l texture should be
- combined with \l color to decal the texture onto the object.
- This property should be set to false to use the texture
- directly, combined with the \l material parameters.
-
- The default value for this property is false.
-*/
-bool QDeclarativeEffect::decal() const
-{
- return d->decal;
-}
-
-void QDeclarativeEffect::setDecal(bool value)
-{
- if (d->decal != value) {
- d->decal = value;
- emit effectChanged();
- }
-}
-
-/*!
- \qmlproperty bool Effect::blending
-
- This property should be set to true if alpha blending should be
- enabled when this effect is active, or false otherwise. The
- default is false.
-
- This property overrides the viewport-specific blending setting
- that is specified by Viewport::blending.
-*/
-bool QDeclarativeEffect::blending() const
-{
- return d->blending;
-}
-
-void QDeclarativeEffect::setBlending(bool value)
-{
- if (d->blending != value) {
- d->blending = value;
- emit effectChanged();
- }
-}
-
-/*!
- \qmlproperty url Effect::texture
-
- Texture effects are defined by this property. A texture is
- provided by means of a QUrl which is then used for texturing.
-
- Textures can also be defined directly as images using the textureImage
- property.
-
- If the value is non-empty, and the texture could not be loaded from
- the QUrl for any reason, then the property will not be changed.
-
- \sa textureImage
-*/
-QUrl QDeclarativeEffect::texture() const
-{
- if (!material())
- return QUrl();
- return material()->textureUrl();
-}
-
-void QDeclarativeEffect::setTexture(const QUrl& value)
-{
- if (material() && material()->textureUrl() == value)
- return;
-
- if (d->progress != 0.0)
- {
- d->progress = 0.0;
- emit progressChanged(d->progress);
- }
-
- if (value.isEmpty())
- {
- if (material())
- {
- material()->setTextureUrl(value);
- emit effectChanged();
- }
- }
- else
- {
- d->ensureMaterial();
- // Warning: This will trigger the deletion of the old texure.
- material()->setTextureUrl(value);
- emit effectChanged();
- }
-}
-
-/*!
- \qmlproperty image Effect::textureImage
-
- This property directly defines a texture using an existing QImage.
-
- Textures can also be defined based on a URL using the texture property.
-
- \sa texture
-*/
-QImage QDeclarativeEffect::textureImage() const
-{
- return (material() && material()->texture()) ?
- material()->texture()->image() : QImage();
-}
-
-/*!
- \internal
- Sets this effect to use \value as the image for it's texture.
-
- OpenGL defaults have been overridden to clamp the texture both horizontally and vertically as per QGL::Clamp.
-*/
-void QDeclarativeEffect::setTextureImage(const QImage& value)
-{
- QGLTexture2D * tex;
- d->ensureMaterial();
- if (!material()->texture())
- {
- // Should this texture be parented?
- tex = new QGLTexture2D();
- material()->setTexture(tex);
- } else
- {
- tex = material()->texture();
- }
-
- // Equality test of images can be very expensive, so always assign the
- // value and emit effect changed
- tex->setImage(value);
-
- // prevents artifacts due to texture smoothing wrapping around edges of texture
- tex->setHorizontalWrap(QGL::Clamp);
- tex->setVerticalWrap(QGL::Clamp);
-
- emit effectChanged();
-}
-
-/*!
- \qmlproperty Material Effect::material
-
- Defines the material to apply to items that use this effect.
-*/
-QGLMaterial *QDeclarativeEffect::material() const
-{
- if (!d->palette)
- return 0;
- return d->palette->material(d->materialIndex);
-}
-
-/*!
- \internal
- Sets the material for use with this effect. Creates a QGLMaterialCollection
- to contain it if necessary.
-*/
-void QDeclarativeEffect::setMaterial(QGLMaterial *value)
-{
- d->ensureMaterial();
- if (d->materialIndex != -1)
- d->palette->material(d->materialIndex)->disconnect(this);
- int newIndex = -1;
- if (value)
- newIndex = d->palette->addMaterial(value);
- if (newIndex != d->materialIndex)
- {
- d->materialIndex = newIndex;
- emit effectChanged();
- // TODO: deleting old materials
- if (value)
- connect(value, SIGNAL(materialChanged()), this, SIGNAL(effectChanged()));
- }
-}
-
-/*!
- \qmlproperty real Effect::progress
-
- Tracks how much of a remote resource has been downloaded, where 0.0
- is no progress, and 1.0 is completion.
-*/
-
-/*!
- \internal
- Enable the effect on for a given \a painter.
-*/
-void QDeclarativeEffect::enableEffect(QGLPainter *painter)
-{
- painter->setColor(d->color);
- if (d->materialIndex != -1 && d->palette->material(d->materialIndex))
- {
- painter->setFaceMaterial(QGL::FrontFaces, material()->front());
- painter->setFaceMaterial(QGL::BackFaces, material()->back());
- } else
- painter->setFaceColor(QGL::AllFaces, d->color);
-
- QGLTexture2D *tex = 0;
- if (material())
- tex = material()->texture();
- if (d->useLighting) {
- if (tex && !tex->isNull()) {
- if (d->decal)
- painter->setStandardEffect(QGL::LitDecalTexture2D);
- else
- painter->setStandardEffect(QGL::LitModulateTexture2D);
- tex->bind();
- } else {
- painter->setStandardEffect(QGL::LitMaterial);
- }
- } else {
- if (tex && !tex->isNull()) {
- if (d->decal)
- painter->setStandardEffect(QGL::FlatDecalTexture2D);
- else
- painter->setStandardEffect(QGL::FlatReplaceTexture2D);
-// painter->glActiveTexture(GL_TEXTURE0);
- tex->bind();
- } else {
- painter->setStandardEffect(QGL::FlatColor);
- }
- }
-}
-
-/*!
- \internal
- Disable the effect for a given \a painter.
-*/
-void QDeclarativeEffect::disableEffect(QGLPainter *painter)
-{
- painter->setStandardEffect(QGL::FlatColor);
- painter->setColor(Qt::white);
- painter->glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, 0);
-}
-
-/*!
- \internal
- Set a scenenode's material and effect properties to enact this effect.
-
- The desired functionality should mirror the Mesh::draw(QGLPainter*)
- functionality as closely as possible.
-
- Subclasses can reimplement this function to set desired effects (e.g. user
- effects);
-*/
-void QDeclarativeEffect::applyTo(QGLSceneNode *node)
-{
- d->ensureMaterial();
-
- node->setPalette(d->palette);
- node->setMaterialIndex(d->materialIndex);
-
- Q_ASSERT(node->material());
-
- QGLTexture2D *tex = material()->texture();
- if (tex && !tex->isNull())
- node->material()->setTexture(tex);
-
- // Determine which standard effect to use
- if (d->useLighting) {
- if (tex && !tex->isNull()) {
- if (d->decal)
- node->setEffect(QGL::LitDecalTexture2D);
- else
- node->setEffect(QGL::LitModulateTexture2D);
- } else {
- node->setEffect(QGL::LitMaterial);
- }
- } else {
- if (tex && !tex->isNull()) {
- if (d->decal)
- node->setEffect(QGL::FlatDecalTexture2D);
- else
- node->setEffect(QGL::FlatReplaceTexture2D);
- } else {
- node->setEffect(QGL::FlatColor);
- }
- }
-}
-
-QGLTexture2D *QDeclarativeEffect::texture2D()
-{
- if (!material())
- return 0;
- return material()->texture();
-}
-
-/*!
- Returns the progress of remote resource loading.
- */
-qreal QDeclarativeEffect::progress()
-{
- return d->progress;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick3d/qdeclarativeeffect.h b/src/quick3d/qdeclarativeeffect.h
deleted file mode 100644
index d187952c..00000000
--- a/src/quick3d/qdeclarativeeffect.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QDECLARATIVEEFFECT_P_H
-#define QDECLARATIVEEFFECT_P_H
-
-#include "qt3dquickglobal.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qimage.h>
-#include <QtDeclarative/qdeclarative.h>
-
-#include "qgltexture2d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(QtQuick3D)
-
-class QDeclarativeEffectPrivate;
-class QGLPainter;
-class QGLMaterial;
-class QGLSceneNode;
-
-class Q_QT3D_QUICK_EXPORT QDeclarativeEffect : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY effectChanged)
- Q_PROPERTY(bool useLighting READ useLighting WRITE setUseLighting NOTIFY effectChanged)
- Q_PROPERTY(bool decal READ decal WRITE setDecal NOTIFY effectChanged)
- Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY effectChanged)
- Q_PROPERTY(QUrl texture READ texture WRITE setTexture NOTIFY effectChanged)
- Q_PROPERTY(QImage textureImage READ textureImage WRITE setTextureImage NOTIFY effectChanged)
- Q_PROPERTY(QGLMaterial *material READ material WRITE setMaterial NOTIFY effectChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
-public:
- QDeclarativeEffect(QObject *parent = 0);
- ~QDeclarativeEffect();
-
- virtual QColor color() const;
- virtual void setColor(const QColor& value);
-
- virtual bool useLighting() const;
- virtual void setUseLighting(bool value);
-
- virtual bool decal() const;
- virtual void setDecal(bool value);
-
- virtual bool blending() const;
- virtual void setBlending(bool value);
-
- virtual QUrl texture() const;
- virtual void setTexture(const QUrl& value);
-
- virtual QImage textureImage() const;
- virtual void setTextureImage(const QImage& value);
-
- virtual QGLMaterial *material() const;
- virtual void setMaterial(QGLMaterial *value);
-
- virtual void enableEffect(QGLPainter *painter);
- virtual void disableEffect(QGLPainter *painter);
- virtual void applyTo(QGLSceneNode *node);
-
- virtual qreal progress();
-
-Q_SIGNALS:
- void effectChanged();
- void progressChanged(qreal progress);
-
-protected:
- QGLTexture2D *texture2D();
-
-private:
- QDeclarativeEffectPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeEffect)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick3d/qdeclarativeitem3d.cpp b/src/quick3d/qdeclarativeitem3d.cpp
deleted file mode 100644
index 3e1af640..00000000
--- a/src/quick3d/qdeclarativeitem3d.cpp
+++ /dev/null
@@ -1,1674 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qdeclarativeitem3d.h"
-#include "qdeclarativeviewport.h"
-#include "qdeclarativemesh.h"
-#include "qdeclarativeeffect.h"
-
-#include "qgllightparameters.h"
-#include "qglabstractscene.h"
-#include "qglscenenode.h"
-#include "qglview.h"
-#include "qgraphicstransform3d.h"
-
-#include <QtGui/qevent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-/*!
- \qmlclass Item3D QDeclarativeItem3D
- \brief The Item3D item encapsulates 3D objects and contains all of the properties and methods needed for simple 3D operations.
- part of a QML/3d script.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \section1 Simple 3D Object Definition
-
- The most basic use case for the Item3D class is the creation and display of a
- single simple item in the 3D environment.
-
- Many such items within a 3D environment are defined as a single logical component
- mesh which is treated as a stand-alone object for the purposes of rotation,
- scaling, and user interaction via "picking".
-
- Such an object can easily be defined in QML using the following code:
-
- \code
- Item3D {
- id: teapot
- mesh: Mesh { source: "teapot.bez" }
- effect: Effect {}
- cullFaces: "CullBackFaces"
- }
- \endcode
-
- This simple code will create a 3D item based on the \i teapot.bez mesh using
- back-face culling.
-
- Notice that in this case the effect and mesh are defined within the body of
- the item definition. Where there is little complexity, this method of
- defining items simplifies the resultant code and makes modification of
- the QML easier.
-
- \section1 Embedding Item3D Objects
-
- Consider the following:
-
- \code
- Item3D {
- id: cup
- mesh: Mesh { source: "teacup.bez" }
- effect: Effect {}
- cullFaces: "CullBackFaces"
-
- Item3D {
- id: saucer
- mesh: Mesh { source: "saucer.bez" }
- cullFaces: "CullBackFaces"
- }
-
- position: Qt.vector3d(10, -10, -10)
- }
- \endcode
-
- This demonstrates the capability of embedding one Item3D within another. In
- this case the \i saucer item is a child of the \i cup item.
-
- All transformations applied to the parent item are also applied to the child,
- so in this case both the cup and saucer will be translated based on the
- position vector defined in the cup item's definition.
-
- In this case any additional transformations applied to the child item will not
- affect the parent, and are local only to that item (and to its children if any
- exist).
-
- This allows a user to group together items logically so that transformations and
- user interactions can be applied to groups of objects as if they were a whole.
-
- \section1 Using Sub-nodes of 3D Objects
-
- In more complex applications the user may wish to load a complex mesh
- which is made up of a number of components or nodes which may be organised
- into a tree like structure. In this case they may wish to interact with,
- animate, or otherwise modify individual sub-nodes of a mesh.
-
- Item3D leverages the existing \bold {Qt Object Model} in order to allow QML/3d users
- this type of control over their 3D items.
-
- Consider the following QML script:
-
- \code
- Item3D {
- id: helicoptor
- mesh: helicoptorMesh
- effect: Effect {}
- cullFaces: "CullBackFaces"
-
- transform: [
- Rotation3D {
- id: rotate1
- angle: 5
- axis: Qt.vector3d(1, 0, 0)
- },
- Rotation3D {
- id: rotate2
- angle: 5
- axis: Qt.vector3d(0, 1, 0)
- },
- Rotation3D {
- id: rotate3
- angle: 45
- axis: Qt.vector3d(0, 0, 1)
- }
- ]
-
- Item3D {
- id: rotor
- property bool spin: false
- meshNode: "rotorBladesNode"
- Item3D {meshNode: "rotorHubNode"}
-
- transform: [
- Rotation3D {
- id: rotateBlades
- angle: 0
- axis: Qt.vector3d(0, 0, 1)
- }
- ]
-
- onClicked: { rotor.spin=true }
-
- SequentialAnimation {
- running: rotor.spin
- NumberAnimation {
- target: rotateBlades
- property: "angle"
- to: 360.0
- duration: 750
- easing.type:"OutQuad"
- }
- onCompleted: rotor.spin = false
- }
- }
- }
-
- Mesh {
- id: helicoptorMesh
- source: "bellUH1.3ds"
- }
- \endcode
-
- Obviously this example is much more complex both in structure and behaviour. In
- this case the mesh describes a \i .3ds file of a helicoptor, which is broken down
- discrete sub-components (engine nacelles, rotor, rotor hub, etc), which the user
- may wish to modify or animate individually.
-
- Each child item in this case does not have a mesh explicitly defined, but rather
- inherits the mesh from the parent. However each child item does define a mesh node
- which is part of the parent mesh.
-
- All transformations carried out on the parent item will also be applied to the child.
-
- Child items can, as shown here, have their own \i local transformations and user
- interactions applied. These will be applied only to the node of the mesh which
- is defined for that item. In cases where the mesh is defined heirarchically as a
- tree of nodes, this transformation will therefore be applied to all items in that
- tree which are children of the defined node.
-
- Likewise if the user explicitly declares a child item, such as has been done here with
- the \i rotorHubNode, then the transformations will apply to this item as well (and
- its children, and so on).
-
- It should be noted that no support is currently provided for skeleton animation or
- kinematic control of items. This is left to the user to implement as required.
-
- \section1 Using QML Data Models With Item3D
-
- QDeclarativeItem3D supports standard \l
- {http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#qml-data-models}
- {QML Data Models} with a few caveats.
-
- QDeclarativeItem3D derives from QtDeclarativeItem, and interacts with
- the \l{http://doc.qt.nokia.com/4.7/qml-component.html}{Component} element
- normally. However, there is a delay between between removing an item from
- a model and the cleaning up the corresponding Item3D, so it is recommended
- that Item3D based delegates hide themselves when their index is
- -1 as shown in the photoroom example:
-
- \snippet 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
-
- 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
-
- \sa{http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#qml-data-models}{QML Data Models}
-*/
-
-
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeItem3DPrivate
-{
-public:
- QDeclarativeItem3DPrivate(QDeclarativeItem3D *_item)
- : item(_item)
- , viewport(0)
- , position(0.0f, 0.0f, 0.0f)
- , pivot(0.0f,0.0f,0.0f)
- , usePivot(false)
- , scale(1.0f)
- , mesh(0)
- , effect(0)
- , requireBlockingEffectsCheck(false)
- , light(0)
- , objectPickId(-1)
- , cullFaces(QDeclarativeItem3D::CullDisabled)
- , sortChildren(QDeclarativeItem3D::DefaultSorting)
- , inheritEvents(false)
- , isEnabled(true)
- , isInitialized(false)
- , mainBranchId(0)
- , componentComplete(false)
- {
- }
- ~QDeclarativeItem3DPrivate();
-
- QDeclarativeItem3D *item;
- QDeclarativeViewport *viewport;
- QVector3D position;
- QVector3D pivot;
- bool usePivot;
- qreal scale;
- QDeclarativeMesh *mesh;
- QDeclarativeEffect *effect;
- bool requireBlockingEffectsCheck;
- QGLLightParameters *light;
- int objectPickId;
- QDeclarativeItem3D::CullFaces cullFaces;
- QDeclarativeItem3D::SortMode sortChildren;
-
- bool inheritEvents;
- bool isEnabled;
- bool isInitialized;
- int mainBranchId;
- QString meshNode;
-
- // data property
- static void data_append(QDeclarativeListProperty<QObject> *, QObject *);
-
- // resources property
- static QObject *resources_at(QDeclarativeListProperty<QObject> *, int);
- static void resources_append(QDeclarativeListProperty<QObject> *, QObject *);
- static int resources_count(QDeclarativeListProperty<QObject> *);
-
- // transform property
- static int transform_count(QDeclarativeListProperty<QGraphicsTransform3D> *list);
- static void transform_append(QDeclarativeListProperty<QGraphicsTransform3D> *list, QGraphicsTransform3D *);
- static QGraphicsTransform3D *transform_at(QDeclarativeListProperty<QGraphicsTransform3D> *list, int);
- static void transform_clear(QDeclarativeListProperty<QGraphicsTransform3D> *list);
- QList<QGraphicsTransform3D *> transforms;
-
-
- // pretransform property
- static int pretransform_count(QDeclarativeListProperty<QGraphicsTransform3D> *list);
- static void pretransform_append(QDeclarativeListProperty<QGraphicsTransform3D> *list, QGraphicsTransform3D *);
- static QGraphicsTransform3D *pretransform_at(QDeclarativeListProperty<QGraphicsTransform3D> *list, int);
- static void pretransform_clear(QDeclarativeListProperty<QGraphicsTransform3D> *list);
- QList<QGraphicsTransform3D *> pretransforms;
-
- // transform convenience functions
- QMatrix4x4 localTransforms() const;
- QMatrix4x4 localToWorldMatrix() const;
- QMatrix4x4 worldToLocalMatrix() const;
- bool componentComplete;
-};
-
-QDeclarativeItem3DPrivate::~QDeclarativeItem3DPrivate()
-{
-}
-
-int QDeclarativeItem3DPrivate::transform_count(QDeclarativeListProperty<QGraphicsTransform3D> *list)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- return object->d->transforms.count();
- } else {
- qWarning()<<"Warning: could not find Item3D to query for transformation count.";
- return 0;
- }
-}
-
-void QDeclarativeItem3DPrivate::transform_append(QDeclarativeListProperty<QGraphicsTransform3D> *list, QGraphicsTransform3D *item)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- QList<QGraphicsTransform3D *> *ptrans;
- if (object)
- {
- ptrans = &object->d->transforms;
-
- //We now need to connect the underlying transform so that any change will update the graphical item.
- if (!ptrans->contains(item)) {
- ptrans->append(item);
- QObject::connect(item, SIGNAL(transformChanged()),
- object, SLOT(update()));
- }
- }
- else
- qWarning()<<"Warning: could not find Item3D to add transformation to.";
-}
-
-QGraphicsTransform3D *QDeclarativeItem3DPrivate::transform_at(QDeclarativeListProperty<QGraphicsTransform3D> *list, int idx)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- return object->d->transforms.at(idx);
- } else {
- qWarning()<<"Warning: could not find Item3D to query for transformations";
- return 0;
- }
- return 0;
-}
-
-void QDeclarativeItem3DPrivate::transform_clear(QDeclarativeListProperty<QGraphicsTransform3D> *list)
-{
-
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- object->d->transforms.clear();
- object->update();
- }
- else
- qWarning()<<"Warning: could not find Item3D to clear of transformations";
-}
-
-int QDeclarativeItem3DPrivate::pretransform_count(QDeclarativeListProperty<QGraphicsTransform3D> *list)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- return object->d->pretransforms.count();
- } else {
- qWarning()<<"Warning: could not find Item3D to query for transformation count.";
- return 0;
- }
-}
-
-void QDeclarativeItem3DPrivate::pretransform_append(QDeclarativeListProperty<QGraphicsTransform3D> *list, QGraphicsTransform3D *item)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- QList<QGraphicsTransform3D *> *ptrans;
- if (object)
- {
- ptrans = &object->d->pretransforms;
-
- //We now need to connect the underlying transform so that any change will update the graphical item.
- if (!ptrans->contains(item)) {
- ptrans->append(item);
- QObject::connect(item, SIGNAL(transformChanged()),
- object, SLOT(update()));
- }
- }
- else
- qWarning()<<"Warning: could not find Item3D to add transformation to.";
-}
-
-QGraphicsTransform3D *QDeclarativeItem3DPrivate::pretransform_at(QDeclarativeListProperty<QGraphicsTransform3D> *list, int idx)
-{
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- return object->d->pretransforms.at(idx);
- } else {
- qWarning()<<"Warning: could not find Item3D to query for transformations";
- return 0;
- }
- return 0;
-}
-
-void QDeclarativeItem3DPrivate::pretransform_clear(QDeclarativeListProperty<QGraphicsTransform3D> *list)
-{
-
- QDeclarativeItem3D *object = qobject_cast<QDeclarativeItem3D *>(list->object);
- if (object) {
- object->d->pretransforms.clear();
- object->update();
- }
- else
- qWarning()<<"Warning: could not find Item3D to clear of transformations";
-}
-
-
-
-void QDeclarativeItem3DPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
-{
- // This function is called by the QML runtime to assign children to
- // an item3d. The object 'o' is the new child, and prop->object is the
- // Item3d that is to be the parent.
-
- // Either way we're going to call something like setParent(prop->object)
- // we're just determining whether to use the QDeclarativeItem or QObject
- // version.
-
- // The primary purpose of this function is to divide new children into
- // renderable qml Items and non-renderable QObject derived resources.
- // We want to accept all Items, and and simply ignore non-3d items
- // during drawing.
-
- // It is important that we imitate this behaviour of non-3d
- // QDeclarativeItems so view items will assign dynamically created objects
- // to the Item3d and make them available for drawing.
-
- QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
- if (i)
- i->setParentItem(static_cast<QDeclarativeItem3D *>(prop->object));
- else
- o->setParent(static_cast<QDeclarativeItem3D *>(prop->object));
-}
-
-
-QObject *QDeclarativeItem3DPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
-{
- QObjectList children = prop->object->children();
- if (index < children.count())
- return children.at(index);
- else
- return 0;
-}
-
-void QDeclarativeItem3DPrivate::resources_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
-{
- o->setParent(prop->object);
-}
-
-int QDeclarativeItem3DPrivate::resources_count(QDeclarativeListProperty<QObject> *prop)
-{
- return prop->object->children().count();
-}
-
-/*!
- \internal
- Applies position, scale and rotation transforms for this item3d to matrix
- \a m
-*/
-QMatrix4x4 QDeclarativeItem3DPrivate::localTransforms() const
-{
- QMatrix4x4 m;
- m.translate(position);
- int transformCount = transforms.count();
- if (transformCount>0) {
- // The transformations are applied in reverse order of their
- // lexical appearance in the QML file.
- for (int index = transformCount - 1; index >= 0; --index) {
- transforms.at(index)->applyTo(&m);
- }
- }
- if (scale != 1.0f)
- m.scale(scale);
- return m;
-}
-
-
-/*!
- \internal
-*/
-QDeclarativeItem3D::QDeclarativeItem3D(QObject *parent)
- : QDeclarativeItem(0)
-{
- d = new QDeclarativeItem3DPrivate(this);
-
- QDeclarativeItem *itemParent = qobject_cast<QDeclarativeItem *>(parent);
- if (itemParent) {
- setParentItem(itemParent);
- } else {
- setParent(parent);
- }
-
- // TODO: Handle QDeclarativeItem3D case
-}
-
-/*!
- \internal
-*/
-QDeclarativeItem3D::~QDeclarativeItem3D()
-{
- delete d;
-}
-
-
-
-/*!
- \qmlproperty vector3D Item3D::position
-
- The position in 3D space of this item. The default value for this
- property is (0, 0, 0).
-
- \sa x, y, z
-*/
-
-QVector3D QDeclarativeItem3D::position() const
-{
- return d->position;
-}
-
-void QDeclarativeItem3D::setPosition(const QVector3D& value)
-{
- d->position = value;
- emit positionChanged();
- update();
-}
-
-/*!
- \qmlproperty real Item3D::x
-
- The x position of this item in 3D space. The default value for this
- property is 0.
-
- \sa position, y, z
-*/
-
-qreal QDeclarativeItem3D::x() const
-{
- return d->position.x();
-}
-
-void QDeclarativeItem3D::setX(qreal value)
-{
- d->position.setX(value);
- emit positionChanged();
- update();
-}
-
-/*!
- \qmlproperty real Item3D::y
-
- The y position of this item in 3D space. The default value for this
- property is 0.
-
- \sa position, x, z
-*/
-
-qreal QDeclarativeItem3D::y() const
-{
- return d->position.y();
-}
-
-void QDeclarativeItem3D::setY(qreal value)
-{
- d->position.setY(value);
- emit positionChanged();
- update();
-}
-
-/*!
- \qmlproperty real Item3D::z
-
- The z position of this item in 3D space. The default value for
- this property is 0.
-
- \sa position, x, y
-*/
-
-qreal QDeclarativeItem3D::z() const
-{
- return d->position.z();
-}
-
-void QDeclarativeItem3D::setZ(qreal value)
-{
- d->position.setZ(value);
- emit positionChanged();
- update();
-}
-
-/*!
- \qmlproperty real Item3D::scale
-
- The scaling factor to apply to the item after the transformations
- from the Item3D::transform property. The default value for this
- property is 1.
-
- \sa transform
-*/
-
-qreal QDeclarativeItem3D::scale() const
-{
- return d->scale;
-}
-
-void QDeclarativeItem3D::setScale(qreal value)
-{
- d->scale = value;
- emit scaleChanged();
- update();
-}
-
-/*!
- \qmlproperty list<Transform> Item3D::transform
-
- Generally objects in 3D space will have undergone some number
- of 3D transformation prior to display. Examples of such transformations
- include rotations about the x, y, and z axes, translation, and so on.
-
- Each Item3D maintains a list of transforms to apply to it through this
- property. In scripting terms a transform can be applied as follows:
-
- \code
- Item3D {
- id: teapot
- mesh: Mesh { source: "teapot.bez" }
- transform: [
- Rotation3D {
- id: teapot_rotate1
- angle: 0
- axis: Qt.vector3d(0, 1, 0)
- },
- Rotation3D {
- id: teapot_rotate2
- angle: 0
- axis: Qt.vector3d(0, 0, 1)
- }
- ]
- }
- \endcode
-
- In this example we have two transformations in our list - a rotation around
- the y axis (\c {teapot_rotate1}), and a rotation about the z axis (\c {teapot_rotate2}).
-
- These transformations can be accessed via standard QML scripting methods to achieve
- animations and other effects.
-
- By default this list of transformations is empty.
-
- \sa Rotation3D, Scale3D, Translation3D, scale, position, pretransform
-*/
-
-
-QDeclarativeListProperty<QGraphicsTransform3D> QDeclarativeItem3D::transform()
-{
- return QDeclarativeListProperty<QGraphicsTransform3D>(this, 0, d->transform_append, d->transform_count,
- d->transform_at, d->transform_clear);
-}
-
-/*!
- \qmlproperty list<Transform> Item3D::pretransform
-
- The transformations to apply before all others.
-
- When a model is loaded from an external source such as a 3D
- modeling package, it is usually in an unconventional orientation
- and position. The first step is to rotate, scale, and translate
- it to make it suitable for use as a QML object.
-
- The purpose of the \c pretransform property is to perform such
- "model correction" transformations before \c scale, \c transform,
- and \c position are applied to place the model in its final
- orientation and position in the QML application.
-
- By default this list of transformations is empty.
-
- \sa transform, scale, position
-*/
-
-QDeclarativeListProperty<QGraphicsTransform3D> QDeclarativeItem3D::pretransform()
-{
- return QDeclarativeListProperty<QGraphicsTransform3D>(this, 0, d->pretransform_append, d->pretransform_count,
- d->pretransform_at, d->pretransform_clear);
-}
-
-/*!
- \qmlproperty bool Item3D::inheritEvents
-
- Users are able to interact with 3d items in a scene through (for example) the
- use of the mouse. These, and other, Qt events can be captured by an \l Item3D using the
- same underlying QObject architecture shared by all of Qt.
-
- Often a user will only want an item to capture mouse events for itself, leaving
- child items to handle their mouse events locally. Under many circumstances, however, it
- is necessary for a parent object to collect all mouse events for itself and its child
- items. Usually this inheritance of events is only defined at initialisation for an \l Item3D
-
- The inheritEvents property, however, is a simple boolean property which provides a mechanism
- for both initialisation time and programmatic modification of this.
-
- Setting the property to true connects the signals for all child items to the appropriate
- signals for the item itself. Conversely setting the property to false disconnects the
- events.
-
- The default value for this property is false.
-*/
-bool QDeclarativeItem3D::inheritEvents() const
-{
- return d->inheritEvents;
-}
-
-void QDeclarativeItem3D::setInheritEvents(bool inherit)
-{
- d->inheritEvents = inherit;
-
- //Generally we would only want to
- if (inherit)
- {
- for (int index = 0; index < children().size(); ++index) {
- QDeclarativeItem3D *subItem = qobject_cast<QDeclarativeItem3D *>(children().at(index));
- if (subItem)
- {
- // Proxy the mouse event signals to the parent so that
- // the parent can trap the signal for a group of children.
- QObject::connect(subItem, SIGNAL(clicked()), this, SIGNAL(clicked()));
- QObject::connect(subItem, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
- QObject::connect(subItem, SIGNAL(pressed()), this, SIGNAL(pressed()));
- QObject::connect(subItem, SIGNAL(released()), this, SIGNAL(released()));
- QObject::connect(subItem, SIGNAL(hoverEnter()), this, SIGNAL(hoverEnter()));
- QObject::connect(subItem, SIGNAL(hoverLeave()), this, SIGNAL(hoverLeave()));
- }
- }
- }
- else
- {
- for (int index = 0; index < children().size(); ++index) {
- QDeclarativeItem *subItem = qobject_cast<QDeclarativeItem *>(children().at(index));
- if (subItem)
- {
- // Proxy the mouse event signals to the parent so that
- // the parent can trap the signal for a group of children.
- QObject::disconnect(subItem, SIGNAL(clicked()), this, SIGNAL(clicked()));
- QObject::disconnect(subItem, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
- QObject::disconnect(subItem, SIGNAL(pressed()), this, SIGNAL(pressed()));
- QObject::disconnect(subItem, SIGNAL(released()), this, SIGNAL(released()));
- QObject::disconnect(subItem, SIGNAL(hoverEnter()), this, SIGNAL(hoverEnter()));
- QObject::disconnect(subItem, SIGNAL(hoverLeave()), this, SIGNAL(hoverLeave()));
- }
- }
- }
-}
-
-/*!
- \qmlproperty Mesh Item3D::mesh
-
- Objects in most 3D environments are almost invariably defined as meshes - sets of
- vertices which when linked as polygons form a recognisable 3D object. QtQuick3D currently
- supports a number of these \i {scene formats}, including \i {.obj} file, bezier patches
- \i {(.bez)}, and \i {.3ds} files.
-
- These meshes are abstracted into the \l Mesh class, which is defined for
- an \l Item3D through this property.
-
- The default value for this property is null, so a mesh must be defined in
- order for the item to be displayed
-
- \sa effect
-*/
-
-QDeclarativeMesh *QDeclarativeItem3D::mesh() const
-{
- return d->mesh;
-}
-
-void QDeclarativeItem3D::setMesh(QDeclarativeMesh *value)
-{
- if (d->mesh != value)
- {
- if (d->mesh) {
- if (!d->mesh->deref())
- delete d->mesh;
- }
-
- d->mesh = value;
- //always start off pointing to the default scene mesh object.
- d->mainBranchId = 0;
-
- if (value) {
- d->mesh->ref();
- connect(value, SIGNAL(dataChanged()), this, SIGNAL(meshChanged()));
- connect(value, SIGNAL(dataChanged()), this, SLOT(update()));
- d->requireBlockingEffectsCheck = true;
- }
-
- emit meshChanged();
-
- update();
- }
-}
-
-/*!
- \qmlproperty Effect Item3D::effect
-
- QML 3D items support the use of effects for modifying the display
- of items - texture effects, fog effects, material effects, and so on.
-
- The exact effects correlated with an item are set using this property.
-
- The default value for this propertly is null, and so an effect - even an
- empty one - must be defined if the mesh does not contain its own effects.
-
- \sa Effect, mesh
-*/
-QDeclarativeEffect *QDeclarativeItem3D::effect() const
-{
- return d->effect;
-}
-
-void QDeclarativeItem3D::setEffect(QDeclarativeEffect *value)
-{
- if (d->effect == value)
- return;
- if (d->effect)
- disconnect(d->effect, SIGNAL(effectChanged()), this, SLOT(handleEffectChanged()));
- d->effect = value;
- if (d->effect)
- {
- connect(d->effect, SIGNAL(effectChanged()), this, SLOT(handleEffectChanged()));
- d->requireBlockingEffectsCheck = true;
- }
- emit effectChanged();
- update();
-}
-
-/*!
- \qmlproperty Light Item3D::light
-
- This property defines an item-specific light that will be used
- intead of Viewport::light for rendering this item and its children
- if the value is not null.
-
- \sa Viewport::light
-*/
-
-QGLLightParameters *QDeclarativeItem3D::light() const
-{
- return d->light;
-}
-
-void QDeclarativeItem3D::setLight(QGLLightParameters *value)
-{
- if (d->light != value) {
- if (d->light) {
- disconnect(d->light, SIGNAL(lightChanged()),
- this, SLOT(update()));
- }
- d->light = value;
- if (d->light) {
- connect(d->light, SIGNAL(lightChanged()),
- this, SLOT(update()));
- }
- emit lightChanged();
- update();
- }
-}
-
-/*!
- \qmlproperty list<Item3D> Item3D::children
- \qmlproperty list<Object> Item3D::resources
-
- The children property contains a list of all QDeclarativeItem derived
- child items for this item. This provides logical grouping of items in a
- scene. Transformations that are applied to this item will also affect
- child items. Note that children that are not derived from
- QDeclarativeItem3D will not be rendered at draw time, but will interact
- normally otherwise (e.g. parenting, signal passing etc). Use a
- qobject_cast if you need to check whether a child is an Item3D.
-
- The resources property holds all other children that do not
- directly inherit from QDeclarativeItem, such as effects, meshes, and
- other supporting objects.
-
- Normally it isn't necessary to assign to the children or resources
- properties directly as the QML syntax will take care of the
- assignment depending upon the object's type.
-
- \sa transform
-*/
-
-QDeclarativeListProperty<QObject> QDeclarativeItem3D::resources()
-{
- return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItem3DPrivate::resources_append,
- QDeclarativeItem3DPrivate::resources_count,
- QDeclarativeItem3DPrivate::resources_at);
-}
-
-
-
-/*!
- \qmlproperty list<Object> Item3D::data
-
- This property exists to allow future expansion of the Item3D class to
- include additional data and resources. Currently there is no underlying
- implementation for this.
-*/
-QDeclarativeListProperty<QObject> QDeclarativeItem3D::data()
-{
- return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItem3DPrivate::data_append);
-}
-
-/*!
- \qmlproperty enumeration Item3D::cullFaces
-
- This property defines the culling method to be use on fragments
- within the item's mesh. Culling of an item in 3D space can be
- carried out in a number of ways:
-
- \list
- \o CullDisabled Do not use culling. This is the default value.
- \o CullFrontFaces Cull the front faces of the object.
- \o CullBackFaces Cull the back faces of the object.
- \o CullAllFaces Cull all faces of the object.
- \o CullClockwise Cull faces based on clockwise winding of vertices.
- \endlist
-*/
-QDeclarativeItem3D::CullFaces QDeclarativeItem3D::cullFaces() const
-{
- return d->cullFaces;
-}
-
-void QDeclarativeItem3D::setCullFaces(QDeclarativeItem3D::CullFaces value)
-{
- if (d->cullFaces != value) {
- d->cullFaces = value;
- emit meshChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration Item3D::sortChildren
-
- This property defines the sorting mode to apply to child \l Item3D
- elements when they are drawn.
-
- \list
- \o DefaultSorting No explicit sorting of the children - draw them in
- whatever order is convenient for the system. The system may apply
- its own sorting, grouping similar materials to improve performance.
- This is the default.
- \o BackToFront Sort the children to draw them in back-to-front
- order of their \l position, overriding any system-supplied sorting.
- BackToFront is useful when the children are partially transparent
- and must be drawn in back-to-front order for correct rendering.
- \endlist
-*/
-QDeclarativeItem3D::SortMode QDeclarativeItem3D::sortChildren() const
-{
- return d->sortChildren;
-}
-
-void QDeclarativeItem3D::setSortChildren(QDeclarativeItem3D::SortMode mode)
-{
- if (d->sortChildren != mode) {
- d->sortChildren = mode;
- emit sortChildrenChanged();
- }
-}
-
-/*!
- \internal
- Sets the lighting conditions for this item on the \a painter. The parameters \a currentLight and \a currentLightTransform
- are used to store the current lighting parameters and transforms so that they can be reset on cleanup.
-
- After drawing has finished the drawLightingCleanup() function should be called to restore previous settings.
-
- \sa drawLightingCleanup(), draw()
-*/
-void QDeclarativeItem3D::drawLightingSetup(QGLPainter *painter, const QGLLightParameters *currentLight, QMatrix4x4 &currentLightTransform)
-{
- //Lighting
- if (d->light) {
- currentLight = painter->mainLight();
- currentLightTransform = painter->mainLightTransform();
- painter->setMainLight(d->light);
- }
-}
-
-/*!
- \internal
- Restores the lighting conditions for \a painter to the \a currentLight and \a currentLightTransform. These values are usually
- provided by an earlier call to drawLightingSetup().
-
- \sa drawLightingSetup(), draw()
-*/
-void QDeclarativeItem3D::drawLightingCleanup(QGLPainter *painter, const QGLLightParameters *currentLight, QMatrix4x4 &currentLightTransform)
-{
- if (d->light)
- painter->setMainLight(currentLight, currentLightTransform);
-}
-
-/*!
- \internal
- Sets the effects for this item on the \a painter. The parameters \a viewportBlend and \a effectBlend
- are used to store the current blending parameters so that they can be reset on cleanup.
-
- After drawing has finished the drawEffectCleanup() function should be called to restore previous settings.
-
- \sa drawLightingCleanup(), draw()
-*/
-void QDeclarativeItem3D::drawEffectSetup(QGLPainter *painter, bool &viewportBlend, bool &effectBlend)
-{
- // Blending change for the effect.
- viewportBlend = d->viewport ? d->viewport->blending() : false;
- effectBlend = d->effect ? d->effect->blending() : viewportBlend;
- if (viewportBlend != effectBlend) {
- if (effectBlend)
- glEnable(GL_BLEND);
- else
- glDisable(GL_BLEND);
- }
-
- //Effects
- if (d->effect)
- d->effect->enableEffect(painter);
-}
-
-/*!
- \internal
- Restores the blending settings for \a painter to the \a viewportBlend and \a effectBlend. These values are usually
- provided by an earlier call to drawEffectSetup().
-
- \sa drawEffectSetup(), draw()
-*/
-void QDeclarativeItem3D::drawEffectCleanup(QGLPainter *painter, bool &viewportBlend, bool &effectBlend)
-{
- if (d->effect)
- d->effect->disableEffect(painter);
- if (viewportBlend != effectBlend) {
- if (effectBlend)
- glDisable(GL_BLEND);
- else
- glEnable(GL_BLEND);
- }
-}
-
-/*!
- \internal
- Sets the culling settings for this item.
-
- After drawing has finished the drawCullCleanup() function should be called to restore previous settings.
-
- \sa drawCullCleanup(), draw()
-*/
-void QDeclarativeItem3D::drawCullSetup()
-{
- //Culling
- if ((d->cullFaces & ~CullClockwise) == CullDisabled) {
- glDisable(GL_CULL_FACE);
- } else if (d->cullFaces & CullClockwise) {
- glFrontFace(GL_CW);
- glCullFace(GLenum(d->cullFaces & ~CullClockwise));
- glEnable(GL_CULL_FACE);
- } else {
- glFrontFace(GL_CCW);
- glCullFace(GLenum(d->cullFaces));
- glEnable(GL_CULL_FACE);
- }
-}
-
-/*!
- \internal
- Restores the culling settings after an earlier call to drawCullSetup().
-
- \sa drawCullSetup(), draw()
-*/
-void QDeclarativeItem3D::drawCullCleanup()
-{
- if (d->cullFaces != CullDisabled)
- glDisable(GL_CULL_FACE);
-}
-
-/*!
- \internal
- Applies the transforms for this item on the \a painter.
-
- After drawing has finished the drawTransformCleanup() function should be called to restore previous settings.
-
- \sa drawTransformCleanup(), draw()
-*/
-void QDeclarativeItem3D::drawTransformSetup(QGLPainter *painter)
-{
- //Local and Global transforms
- painter->modelViewMatrix().push();
- painter->modelViewMatrix() *= d->localTransforms();
-}
-
-/*!
- \internal
- Restores the previous model-view matrix settings for \a painter after an earlier call to drawTransformSetup().
-
- \sa drawTransformSetup(), draw()
-*/
-void QDeclarativeItem3D::drawTransformCleanup(QGLPainter *painter)
-{
- //Unset parameters for transforms, effects etc.
- painter->modelViewMatrix().pop();
-}
-
-/*!
- \internal
- Iterate through all of the child items for the current item and call their drawing functions. Children will
- be drawn in the order specified unless specified by sortChildren(), in which case they will be drawn in the
- order specified (usually this will be back-to-front, to allow for transparency of objects).
-
- \sa sortMode(), draw()
-*/
-void QDeclarativeItem3D::drawChildren(QGLPainter *painter)
-{
- // Find all 3d children for drawing
- QList<QDeclarativeItem3D *> list;;
- foreach (QObject* o, children())
- {
- if (QDeclarativeItem3D *item3d = qobject_cast<QDeclarativeItem3D*>(o))
- {
- list.append(item3d);
- }
- }
-
- if (d->sortChildren == QDeclarativeItem3D::BackToFront) {
- // Collect up the transformed z positions of all children.
- QList<qreal> zlist;
- QMatrix4x4 mv = painter->modelViewMatrix();
- for (int index = 0; index < list.size(); ++index) {
- QVector3D position = list.at(index)->position();
- zlist.append(mv.map(position).z());
- }
-
- // Sort the item list (Caution: really dumb sort algorithm).
- for (int i = 0; i < list.size() - 1; ++i) {
- for (int j = i + 1; j < list.size(); ++j) {
- if (zlist.at(i) > zlist.at(j)) {
- qSwap(list[i], list[j]);
- qSwap(zlist[i], zlist[j]);
- }
- }
- }
- }
- for (int index = 0; index < list.size(); ++index)
- list.at(index)->draw(painter);
-}
-
-/*!
- \internal
- Performs the actual drawing of the Item3D using \a painter.
-
- If the item is set to object picking mode this includes all of the infrastructure needed
- to support picking of objects.
-
- The basic premise of the draw function should be familiar to users of OpenGL or similar
- graphics libraries. Essentially it is a stepwise progress through the following stages:
-
- \list
- \i 1. Iterate through the child objects of the item and set all lighting parameters found.
- \i 2. Set up culling mode in the painter.
- \i 3. Set effects if they exist.
- \i 4. Set all local model view transformations for this item.
- \i 5. Draw this item.
- \i 6. Iterate through the child objects of the item and draw all child items.
- \i 7. Unset the appropriate parameters and states.
- \endlist
-
-
-
- \sa drawItem(), drawLightingSetup(), drawCullSetup(), drawEffectSetup(), drawChildren(), drawTransformSetup()
-*/
-void QDeclarativeItem3D::draw(QGLPainter *painter)
-{
- // Bail out if this item and its children have been disabled.
- if (!d->isEnabled)
- return;
- if (!d->isInitialized)
- initialize(painter);
-
- //Setup picking
- int prevId = painter->objectPickId();
- painter->setObjectPickId(d->objectPickId);
-
- //Setup effect (lighting, culling, effects etc)
- const QGLLightParameters *currentLight = 0;
- QMatrix4x4 currentLightTransform;
- drawLightingSetup(painter, currentLight, currentLightTransform);
- bool viewportBlend, effectBlend;
- drawEffectSetup(painter, viewportBlend, effectBlend);
- drawCullSetup();
-
- //Local and Global transforms
- drawTransformSetup(painter);
-
- //Drawing
- drawItem(painter);
- drawChildren(painter);
-
- //Cleanup
- drawTransformCleanup(painter);
- drawLightingCleanup(painter, currentLight, currentLightTransform);
- drawEffectCleanup(painter, viewportBlend, effectBlend);
- drawCullCleanup();
-
- //Reset pick id.
- painter->setObjectPickId(prevId);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeViewport::setItemViewport(QDeclarativeItem3D *item)
-{
- item->d->viewport = this;
-}
-
-/*!
- \internal
- The process of initialising an /l Object3d is a critical step, particularly in
- complex scenes. This function initialises the item in \a viewport, and using \a painter.
-
- During the initialisation process objects are registered as being \i pickable (ie. able
- to be clicked on with the mouse.
-
- Additionally, in the case of \l Item3D objects which refer to sub-nodes of a mesh, this
- function performs all of the splitting of meshes into sub-branches ready for local
- control by the item.
-*/
-void QDeclarativeItem3D::initialize(QGLPainter *painter)
-{
- if (d->isInitialized) return;
-
- if (!d->viewport)
- {
- if (QDeclarativeItem3D* parentItem =
- qobject_cast<QDeclarativeItem3D*>(parent()))
- {
- d->viewport = parentItem->d->viewport;
- Q_ASSERT(d->viewport);
- }
- }
-
- d->objectPickId = d->viewport->registerPickableObject(this);
-
- //Setup mesh sub-nodes if possible.
- if (mesh() && !meshNode().isEmpty()) {
- int branchNumber = mesh()->createSceneBranch(meshNode());
- if (branchNumber>=0) {
- d->mainBranchId = branchNumber;
- }
- else {
- qWarning()<< "3D item initialization failed: unable to find the specified mesh-node. Defaulting to default node.";
- d->mainBranchId = 0;
- }
- }
-
- for (int index = 0; index < children().size(); ++index) {
- QDeclarativeItem3D *item = qobject_cast<QDeclarativeItem3D *>(children().at(index));
- if (item) {
- //Event inheritance is generally only declared at initialization, but can also be done at runtime
- //if the user wishes (though not recommended).
- if (inheritEvents()) {
- // Proxy the mouse event signals to the parent so that
- // the parent can trap the signal for its children.
- QObject::connect(item, SIGNAL(clicked()), this, SIGNAL(clicked()));
- QObject::connect(item, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
- QObject::connect(item, SIGNAL(pressed()), this, SIGNAL(pressed()));
- QObject::connect(item, SIGNAL(released()), this, SIGNAL(released()));
- QObject::connect(item, SIGNAL(hoverEnter()), this, SIGNAL(hoverEnter()));
- QObject::connect(item, SIGNAL(hoverLeave()), this, SIGNAL(hoverLeave()));
- }
- //if the item has no mesh of its own and no meshnode is declared we give it the mesh from the current item.
- if (!item->mesh() && !item->meshNode().isEmpty()) {
- item->setMesh(mesh());
- }
-
- d->viewport->setItemViewport(item);
- item->initialize(painter);
- }
- }
- d->isInitialized = true;
-}
-
-/*!
- Returns true if the initialize() has been called, returns false otherwise.
-
- \sa initialize()
-*/
-bool QDeclarativeItem3D::isInitialized() const
-{
- return d->isInitialized;
-}
-
-
-void QDeclarativeItem3D::componentComplete()
-{
- QDeclarativeItem::componentComplete();
- d->componentComplete = true;
- // Now that we have all the mesh and subnode information we need, if we haven't already, then it's time to setup the mesh scene objects.
- if (mesh() && !meshNode().isEmpty() && d->mainBranchId==0) {
- int branchNumber = mesh()->createSceneBranch(meshNode());
- if (branchNumber>=0) {
- d->mainBranchId = branchNumber;
- }
- else {
- qWarning()<< "3D item initialization failed: unable to find the specified mesh-node. Defaulting to default node.";
- d->mainBranchId = 0;
- }
- }
- update();
-}
-
-/*!
- \internal
- The \c drawItem function performs the actual drawing of the mesh branch which corresponds
- to the section of the mesh being drawn by the \l Item3D to a specific \a painter.
-
- This function does perform one transform - the pretransform, which is usually used to
- rotate the item to give it the correct initial spatial orientation.
-
- \sa pretransform()
-*/
-void QDeclarativeItem3D::drawItem(QGLPainter *painter)
-{
- int transformCount = d->pretransforms.count();
- if (transformCount>0) {
- painter->modelViewMatrix().push();
-
- QMatrix4x4 *m = const_cast<QMatrix4x4 *>(&painter->modelViewMatrix().top());
-
- // Pre-transforms for orienting the model.
- for (int index = transformCount - 1; index >= 0; --index) {
- d->pretransforms.at(index)->applyTo(m);
- }
- }
-
- if (d->mesh)
- {
- d->mesh->draw(painter, d->mainBranchId);
- }
-
- if (transformCount>0) {
- painter->modelViewMatrix().pop();
- }
-}
-
-/*!
- \relates QDeclarativeItem3D
- Print a description of \a item to the console.
-
- If \a detailed is true (which it is by default) then all the properties
- of each node are printed.
-
- If \a detailed is false, then just one line is printed with the name and
- some identifying information including a unique id for the node.
-
- The \a indent argument is used internally.
-*/
-void qDumpItem(QDeclarativeItem3D *item, bool detailed, int indent)
-{
- if (item)
- {
- QDeclarativeMesh *mesh = item->mesh();
- QString ind;
- ind.fill(QLatin1Char(' '), indent * 4);
- if (mesh)
- {
- QGLSceneNode *node = mesh->getSceneObject();
- if (node)
- qDumpScene(node, detailed, indent + 1);
- else
- qDebug("%sMesh %p - %s (no node)", qPrintable(ind), mesh, qPrintable(mesh->objectName()));
- }
- else
- {
- qDebug("%sItem %p - %s (no mesh)", qPrintable(ind), item, qPrintable(item->objectName()));
- }
- QObjectList kids = item->children();
- for (int i = 0; i < kids.size(); ++i)
- {
- QDeclarativeItem3D *it = qobject_cast<QDeclarativeItem3D*>(kids.at(i));
- qDumpItem(it, detailed, indent + 1);
- }
- }
-}
-
-/*!
- Calculates and returns a matrix that transforms local coordinates into
- world coordinates (i.e. coordinates untransformed by any item3d's
- transforms).
-*/
-QMatrix4x4 QDeclarativeItem3DPrivate::localToWorldMatrix() const
-{
- QMatrix4x4 result;
-
- result = localTransforms() * result;
- QDeclarativeItem3D *anscestor = qobject_cast<QDeclarativeItem3D *>(item->parent());
- while (anscestor)
- {
- result = anscestor->d->localTransforms() * result;
- anscestor = qobject_cast<QDeclarativeItem3D *>(anscestor->parent());
- }
- return result;
-}
-
-/*!
- Calculates and returns a matrix that transforms world coordinates into
- coordinates relative to this Item3D.
-*/
-QMatrix4x4 QDeclarativeItem3DPrivate::worldToLocalMatrix() const
-{
- bool inversionSuccessful;
- QMatrix4x4 result = localToWorldMatrix().inverted(&inversionSuccessful);
- if (inversionSuccessful)
- return result;
- qWarning() << "QDeclarativeItem3D - matrix inversion failed trying to generate worldToLocal Matrix";
- return QMatrix4x4();
-}
-
-/*!
- Returns the position of a local \a point in world space (i.e. not
- transformed by this item, it's parents, the camera etc).
-*/
-QVector3D QDeclarativeItem3D::localToWorld(const QVector3D &point) const
-{
- return d->localToWorldMatrix() * point;
-}
-
-/*!
- Returns the position of a point in world space in local coordinates.
-*/
-QVector3D QDeclarativeItem3D::worldToLocal(const QVector3D &point) const
-{
- return d->worldToLocalMatrix() * point;
-}
-
-/*!
- \internal
- This function handles the standard mouse events for the item as contained in \a e.
-
- Returns the boolean value of the regular QObject::event() function.oo
-*/
-
-bool QDeclarativeItem3D::event(QEvent *e)
-{
- // Convert the raw event into a signal representing the user's action.
- if (e->type() == QEvent::MouseButtonPress) {
- QMouseEvent *me = (QMouseEvent *)e;
- if (me->button() == Qt::LeftButton)
- emit pressed();
- } else if (e->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *me = (QMouseEvent *)e;
- if (me->button() == Qt::LeftButton) {
- emit released();
- if (me->x() >= 0) // Positive: inside object, Negative: outside.
- emit clicked();
- }
- } else if (e->type() == QEvent::MouseButtonDblClick) {
- emit doubleClicked();
- } else if (e->type() == QEvent::Enter) {
- emit hoverEnter();
- } else if (e->type() == QEvent::Leave) {
- emit hoverLeave();
- }
- return QObject::event(e);
-}
-
-void QDeclarativeItem3D::handleEffectChanged()
-{
- d->requireBlockingEffectsCheck = true;
- update();
-}
-
-/*!
- \qmlproperty string Item3D::meshNode
-
- This property is a simple string which refers to the node in the \l Mesh object which
- is associated with this \l Item3D.
-
- \sa mesh
-*/
-QString QDeclarativeItem3D::meshNode() const
-{
- return d->meshNode;
-}
-
-void QDeclarativeItem3D::setMeshNode(const QString &node)
-{
- //the actual instantiation of the node as the mesh itself is undertaken in the initialize function.
- d->meshNode = node;
-}
-
-/*!
- \internal
- Update the \l Viewport with which this item is associated.
-*/
-void QDeclarativeItem3D::update()
-{
- if (d->requireBlockingEffectsCheck && d->effect && d->mesh && d->componentComplete)
- {
- QGLSceneNode *n = 0;
- if (!meshNode().isEmpty())
- n = d->mesh->getSceneObject(meshNode());
- if (!n)
- n = d->mesh->getSceneBranch(d->mainBranchId);
- if (!n)
- {
- n = d->mesh->getSceneObject();
- }
- if (n)
- {
- QList<QGLSceneNode*> k = n->allChildren();
- k.prepend(n);
- for (int i = 0; i < k.size(); ++i)
- {
- // If the effect has a texture, make sure the mesh does too
- bool hasTexture = (!d->effect->texture().isEmpty() ||
- (!d->effect->textureImage().isNull()));
- bool missingTextureCoordinates =
- k.at(i)->geometry().hasField(QGL::Position) &&
- !k.at(i)->geometry().hasField(QGL::TextureCoord0);
- if ( hasTexture && missingTextureCoordinates )
- {
- qWarning() << "QGLSceneNode" << k.at(i)->objectName() << "from" << d->mesh->source() << "is missing texture coordinates. Dummy coordinates are being generated, which may take some time.";
- k.at(i)->geometry().generateTextureCoordinates();
- }
-
- QGLSceneNode* sceneObject;
- if (!this->meshNode().isEmpty())
- {
- sceneObject = d->mesh->getSceneObject(meshNode());
- } else
- sceneObject = d->mesh->getSceneObject();
-
- if (sceneObject)
- {
- QList<QGLSceneNode*> k = n->allChildren();
- k.prepend(n);
- if (this->effect())
- {
- for (int i = 0; i < k.size(); ++i)
- {
- this->effect()->applyTo(k.at(i));
- }
- }
- }
- }
- }
- d->requireBlockingEffectsCheck = false;
- }
- if (d->viewport)
- d->viewport->update3d();
-}
-
-/*!
- \qmlproperty bool Item3D::enabled
-
- This property should be set to true to enable the drawing
- of this item and its children. Set this property to false
- to disable drawing. The default value is true.
-
- \sa mesh
-*/
-bool QDeclarativeItem3D::isEnabled() const
-{
- return d->isEnabled;
-}
-
-void QDeclarativeItem3D::setEnabled(bool value)
-{
- if (d->isEnabled != value) {
- d->isEnabled = value;
- emit enabledChanged();
- }
-}
-
-/*!
- Returns the unique pick ID for this item.
-*/
-int QDeclarativeItem3D::objectPickId() const
-{
- return d->objectPickId;
-}
-
-/*!
- \qmlsignal Item3D::onClicked()
-
- This signal is emitted when the item is clicked. Picking must be enabled for this to have any effect.
-*/
-
-
-/*!
- \qmlsignal Item3D::onDoubleClicked()
-
- This signal is emitted when the item is double clicked. Picking must be enabled for this to have any effect.
-
-*/
-
-
-/*!
- \qmlsignal Item3D::onPressed()
-
- This signal is emitted when the item detects a mouse-button-down event. Picking must be enabled
- for this to have any effect.
-*/
-
-
-/*!
- \qmlsignal Item3D::onReleased()
-
- This signal is emitted when the item detects a mouse-button-released event. Picking must be enabled
- for this to have any effect.
-*/
-
-
-/*!
- \qmlsignal Item3D::onHoverEnter()
-
- This signal is emitted when a mouseover of the item is detected. It relies on object picking to be
- of use.
-*/
-
-
-/*!
- \qmlsignal Item3D::onHoverLeave()
-
- This signal is emitted when the mouseover of the item ceases. It relies on object picking to be
- used.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/quick3d/qdeclarativeitem3d.h b/src/quick3d/qdeclarativeitem3d.h
deleted file mode 100644
index 5645897f..00000000
--- a/src/quick3d/qdeclarativeitem3d.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QDECLARATIVEITEM3D_H
-#define QDECLARATIVEITEM3D_H
-
-#include "qt3dquickglobal.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qvector3d.h>
-
-#include <QtDeclarative/qdeclarativeitem.h>
-
-#include "qglscenenode.h"
-#include "qglpainter.h"
-#include "qgraphicstransform3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeItem3DPrivate;
-class QDeclarativeMesh;
-class QDeclarativeEffect;
-class QDeclarativeViewport;
-class QDeclarativeState;
-class QDeclarativeTransition;
-
-class Q_QT3D_QUICK_EXPORT QDeclarativeItem3D : public QDeclarativeItem
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_ENUMS(SortMode)
- Q_ENUMS(CullFace)
- Q_FLAGS(CullFaces)
- Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY positionChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY positionChanged)
- Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY positionChanged)
- Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
- Q_PROPERTY(QDeclarativeListProperty<QGraphicsTransform3D> transform READ transform DESIGNABLE false FINAL)
- Q_PROPERTY(QDeclarativeListProperty<QGraphicsTransform3D> pretransform READ pretransform DESIGNABLE false FINAL)
- Q_PROPERTY(QDeclarativeMesh *mesh READ mesh WRITE setMesh NOTIFY meshChanged)
- Q_PROPERTY(QDeclarativeEffect *effect READ effect WRITE setEffect NOTIFY effectChanged)
- Q_PROPERTY(QGLLightParameters *light READ light WRITE setLight NOTIFY lightChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources DESIGNABLE false)
- Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
- Q_PROPERTY(CullFaces cullFaces READ cullFaces WRITE setCullFaces NOTIFY meshChanged)
- Q_PROPERTY(SortMode sortChildren READ sortChildren WRITE setSortChildren NOTIFY sortChildrenChanged)
- Q_PROPERTY(QString meshNode READ meshNode WRITE setMeshNode NOTIFY meshNodeChanged)
- Q_PROPERTY(bool inheritEvents READ inheritEvents WRITE setInheritEvents NOTIFY inheritEventsChanged)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
- Q_CLASSINFO("DefaultProperty", "data")
-public:
- QDeclarativeItem3D(QObject *parent = 0);
- ~QDeclarativeItem3D();
-
- enum CullFace
- {
- CullDisabled = 0,
- CullFrontFaces = 0x0404, // GL_FRONT
- CullBackFaces = 0x0405, // GL_BACK
- CullAllFaces = 0x0408, // GL_FRONT_AND_BACK
- CullClockwise = 0x10000
- };
- Q_DECLARE_FLAGS(CullFaces, CullFace)
-
- enum SortMode
- {
- DefaultSorting,
- BackToFront
- };
-
- QVector3D position() const;
- void setPosition(const QVector3D& value);
-
- qreal x() const;
- void setX(qreal value);
- qreal y() const;
- void setY(qreal value);
- qreal z() const;
- void setZ(qreal value);
-
- qreal scale() const;
- void setScale(qreal value);
-
- QDeclarativeMesh *mesh() const;
- void setMesh(QDeclarativeMesh* value);
-
- bool inheritEvents() const;
- void setInheritEvents(bool inherit);
-
- QDeclarativeEffect *effect() const;
- void setEffect(QDeclarativeEffect *value);
-
- QGLLightParameters *light() const;
- void setLight(QGLLightParameters *value);
-
- QDeclarativeListProperty<QObject> data();
- QDeclarativeListProperty<QObject> resources();
-
- QDeclarativeListProperty<QGraphicsTransform3D> transform();
- QDeclarativeListProperty<QGraphicsTransform3D> pretransform();
-
- CullFaces cullFaces() const;
- void setCullFaces(CullFaces value);
-
- SortMode sortChildren() const;
- void setSortChildren(SortMode mode);
-
- QString meshNode() const;
- void setMeshNode(const QString &);
-
- bool isEnabled() const;
- void setEnabled(bool value);
-
- virtual void draw(QGLPainter *painter);
- virtual void initialize(QGLPainter *painter);
- bool isInitialized() const;
-
- Q_INVOKABLE QVector3D localToWorld(const QVector3D &point = QVector3D()) const;
- Q_INVOKABLE QVector3D worldToLocal(const QVector3D &point = QVector3D()) const;
-
- void componentComplete();
-
- int objectPickId() const;
-
-public Q_SLOTS:
- void update();
-
-protected:
- virtual void drawLightingSetup(QGLPainter *painter, const QGLLightParameters *currentLight, QMatrix4x4 &currentLightTransform);
- virtual void drawLightingCleanup(QGLPainter *painter, const QGLLightParameters *currentLight, QMatrix4x4 &currentLightTransform);
-
- virtual void drawCullSetup();
- virtual void drawCullCleanup();
-
- virtual void drawEffectSetup(QGLPainter *painter, bool &viewportBlend, bool &effectBlend);
- virtual void drawEffectCleanup(QGLPainter *painter, bool &viewportBlend, bool &effectBlend);
-
- virtual void drawChildren(QGLPainter *painter);
- virtual void drawItem(QGLPainter *painter);
-
- virtual void drawTransformSetup(QGLPainter *painter);
- virtual void drawTransformCleanup(QGLPainter *painter);
-
- bool event(QEvent *e);
-
-private Q_SLOTS:
- void handleEffectChanged();
-
-Q_SIGNALS:
- void positionChanged();
- void scaleChanged();
- void rotationChanged();
- void meshChanged();
- void meshNodeChanged();
- void effectChanged();
- void lightChanged();
- void clicked();
- void doubleClicked();
- void pressed();
- void released();
- void hoverEnter();
- void hoverLeave();
- void inheritEventsChanged();
- void enabledChanged();
- void sortChildrenChanged();
-
-private:
- QDeclarativeItem3DPrivate *d;
-
- friend class QDeclarativeItem3DPrivate;
- friend class QDeclarativeViewport;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeItem3D::CullFaces)
-
-Q_QT3D_QUICK_EXPORT void qDumpItem(QDeclarativeItem3D *item, bool detailed = true, int indent = 0);
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeItem3D)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick3d/qdeclarativemesh.cpp b/src/quick3d/qdeclarativemesh.cpp
deleted file mode 100644
index 25b405b2..00000000
--- a/src/quick3d/qdeclarativemesh.cpp
+++ /dev/null
@@ -1,722 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qdeclarativemesh.h"
-
-#include "qglabstractscene.h"
-#include "qglscenenode.h"
-#include "qglmaterial.h"
-#include "qglmaterialcollection.h"
-
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtCore/qlist.h>
-
-/*!
- \qmlclass Mesh QDeclarativeMesh
- \brief The Mesh item provides a means of abstracting 3D mesh and geometry representations in
- a way that can be used in QML. The Mesh class contains necessary properties and methods for
- display and manipulation of 3d objects of this type.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \section1 Underlying Architecture
-
- QML/3d Mesh objects are a QML enabled means of representing any scene class based
- on the \l QGLAbstractScene class.
-
- In cases where the scene is composed of multiple nodes (for example, in a \i .3ds file)
- the mesh allows users to split away branches of the tree and manipulate them in
- isolation from the original scene graph.
-
- In order to achieve this the mesh object contains a map correlating numeric identifiers
- for individual branches with specific \l QGLSceneNode objects which are taken from
- the original scene.
-
- More details on achieving this can be found in the \l Item3D class.
-
- \section1 Specifying Simple Mesh Objects
-
- Like other objects in QML/3d, Mesh objects are created by the standard QML syntax for
- objects. Meshes should always specify an appropriate file containing the data for
- the Mesh,
-
- \code
- Mesh {source: "model.obj"}
- \endcode
-
- For objects loaded from the network we can wait for an "onLoaded" signal in QML (from the
- loaded() signal in the Mesh class) before performing specific actions. For example:
-
- \code
- Item3D {
- id: theMesh
- mesh: Mesh {
- source: "http://www.example_3d_model_url.com/sample.obj"
- onLoaded:{theMesh.effect=theEffect}
- }
-
- Effect {
- id: theEffect
- texture: ":/qml/texture.jpg" }
- }
- }
- \endcode
-
- This code will wait until the mesh has been fully loaded before attempting to apply the effects.
-*/
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeMeshPrivate
-{
-public:
- QDeclarativeMeshPrivate()
- : dataReply(0)
- , scene(0)
- , nextSceneBranchId(0)
- , mainSceneObject(NULL)
- , refCount(1)
- , completed(false)
- , loaded(false)
- , dumpInfo(false)
- {}
- ~QDeclarativeMeshPrivate()
- {
- delete scene;
- }
-
- struct branchObject {
- QObject *previousParent;
- QGLSceneNode *rootSceneObject;
- };
-
- QUrl data;
- QString meshName;
- QDeclarativeMesh *parentMesh;
- QNetworkReply *dataReply;
- QGLAbstractScene *scene;
- int nextSceneBranchId;
- QMap<int, branchObject> sceneBranches;
- QList<QGLSceneNode *>sceneObjects;
- QGLSceneNode *mainSceneObject;
- QList<QGLMaterial *> connected;
- int refCount;
- bool completed;
- bool loaded;
- QString options;
- bool dumpInfo;
-};
-
-/*!
- \internal
- Construct a \l Mesh object with \a parent as its parent.
-*/
-QDeclarativeMesh::QDeclarativeMesh(QObject *parent)
- : QObject(parent)
-{
- d = new QDeclarativeMeshPrivate();
-}
-
-/*!
- \internal
- Destroy the \l Mesh object and free any unneeded memory.
-*/
-QDeclarativeMesh::~QDeclarativeMesh()
-{
- delete d;
-}
-
-/*!
- \qmlproperty url Mesh::source
-
- Each mesh requires a set of data that describes (among other things) vertices
- transformations, textures, and so on. This data is generally stored in files and
- specified via the source property.
-
- Source files can be of any type supported by QtQuick3D. The types of file currently
- supported can be found in the \c sceneFormat plugins, with \i .3ds, \i .bez, \i. obj
- files currently being supported.
-
- Also due to limitations of 3rd party libraries, .dxf support is rather limited.
- Only 3d components (no 2d lines and such supported), and there are also issues with
- loading newer file types (everything up to the 2004-2006 file format seems to work,
- anything after we've had issues with).
-
- Meshes can also be stored within QRC files and loaded via the standard resource
- mechanisms, however there may be issues with some esoteric remote resource loading
- requirements within the different file types.
-*/
-
-QUrl QDeclarativeMesh::source() const
-{
- return d->data;
-}
-
-void QDeclarativeMesh::setSource(const QUrl& value)
-{
- if (d->data == value)
- return;
- d->data = value;
- if (d->data.scheme() == QLatin1String("file")) {
- QGLAbstractScene *s = QGLAbstractScene::loadScene(d->data.toLocalFile(),
- QString(), d->options);
- setScene(s);
- } else if (d->data.scheme().toLower() == QLatin1String("qrc")) {
- // strips off any qrc: prefix and any excess slashes and replaces it with :/
- d->data.setScheme("");
- QGLAbstractScene *s = QGLAbstractScene::loadScene(
- QLatin1String(":")+d->data.toString(),
- QString(), d->options);
- setScene(s);
- } else {
- //network loading
- QGLAbstractScene *s = QGLAbstractScene::loadScene(d->data,QString(), d->options);
- connect(s, SIGNAL(sceneUpdated()), this, SLOT(dataRequestFinished()));
- }
-}
-
-/*!
- \qmlproperty string Mesh::meshName
-
- Users can associate a name with a mesh to facilitate easy finding or
- description of a mesh.
-*/
-QString QDeclarativeMesh::meshName() const
-{
- return d->meshName;
-}
-
-void QDeclarativeMesh::setMeshName(const QString& value)
-{
- bool emitDataChanged = false;
- if (d->meshName != value)
- {
- d->meshName = value;
- emitDataChanged = true;
- }
- if (d->loaded && d->scene) {
- QGLSceneNode *insertObject;
- if (value.isEmpty())
- insertObject = getSceneObject();
- else
- insertObject = getSceneObject(value);
- if (!insertObject && !value.isEmpty()) {
- qWarning() << "could not find" << value << "available:" << getSceneObjectNames();
- } else if (!insertObject) {
- qWarning() << "could not find main object in scene!";
- }
-
- //Add the object: if null it will make the object non-drawable, but still able
- //to run.
- addSceneBranch(insertObject);
- emitDataChanged = true;
- }
- if (emitDataChanged)
- emit dataChanged();
-}
-
-/*!
- \qmlproperty string Mesh::options
-
- The behaviour of the underlying file loader can be controlled by
- string encoded options. Consult the documentation for each loader for
- the options available.
-
- Specifies the current options for loading this mesh. The default value
- is the null string, meaning no options are applied.
-*/
-QString QDeclarativeMesh::options() const
-{
- return d->options;
-}
-
-void QDeclarativeMesh::setOptions(const QString &options)
-{
- if (options != d->options)
- {
- d->options = options;
- emit optionsChanged();
- }
-}
-
-/*!
- \internal
- Once the request for data has been finished the \l Mesh class is now free to load
- the scene.
-*/
-void QDeclarativeMesh::dataRequestFinished()
-{
- //other processing may be required, but for now, simply emit a
- //change of data signal.
- QGLAbstractScene *sceneData = qobject_cast<QGLAbstractScene*>(sender());
-
- if (sceneData) {
- if (sceneData == d->scene)
- emit dataChanged();
- else
- setScene(sceneData);
- } else {
- qWarning("Data request recieved a signal from a class other than a valid scene.");
- }
-}
-
-/*!
- \internal
- Because the branches of the overall scene are essentially /i moveable, and the
- standard methods of getting objects/names from a scene rely on a single tree,
- the \l Mesh class supports its own list of mesh objects in the scene which is
- taken on startup from the normal \l QGLAbstractScene based class for the current
- mesh.
-
- This means that object lookup can be performed at any time without having to
- reconstitute the original scene or maintain logical links between split branches.
-
- As an added advantage it also eliminates the (minor) additional cost of having
- to traverse the scene-graph/tree in order to locate objects.
-
- \sa QGLAbstractScene
-*/
-void QDeclarativeMesh::initSceneObjectList()
-{
- d->sceneObjects.clear();
- if (d->scene) {
- QList<QObject *> objs = d->scene->objects();
- for (int index = 0; index < objs.count(); ++index) {
- QGLSceneNode *node = qobject_cast<QGLSceneNode *>(objs.at(index));
- if (node)
- d->sceneObjects.append(node);
- }
- QGLSceneNode *old = d->mainSceneObject;
- d->mainSceneObject = d->scene->mainNode();
- if (old != d->mainSceneObject)
- emit nodeChanged();
- }
-}
-
-/*!
- \qmlproperty QGLSceneNode Mesh::getSceneObject
-
- Get the main scene node for the \l QGLAbstractScene associated with this mesh.
-*/
-QGLSceneNode *QDeclarativeMesh::getSceneObject()
-{
- //This variant of the function gets the main scene object for the scene
- if (!d->mainSceneObject)
- initSceneObjectList();
-
- return d->mainSceneObject;
-}
-
-/*!
- \internal
- Get the scene object called \a name, specified as a QString, and retrieve the
- scene object in this mesh which corresponds to it.
-*/
-QGLSceneNode *QDeclarativeMesh::getSceneObject(const QString &name)
-{
- //This variant of the function gets the mesh scene object for a scene
- //based on the name of the object.
- if (d->sceneObjects.empty())
- initSceneObjectList();
-
- foreach (QGLSceneNode *object, d->sceneObjects) {
- if (object && object->objectName().startsWith(name))
- {
- return object;
- }
- }
-
- return NULL;
-}
-
-/*!
- \internal
- Used mainly for diagnostic purposes this function returns a QStringList containing
- all of the object names for the given mesh.
-*/
-QStringList QDeclarativeMesh::getSceneObjectNames()
-{
- //Get a string list of all mesh object names in the scene.
- if (d->sceneObjects.empty())
- initSceneObjectList();
-
- QStringList names;
- foreach (QGLSceneNode *object, d->sceneObjects) {
- if (object) {
- QString name = object->objectName();
- if (!name.isEmpty())
- names += name;
- }
- }
- return names;
-}
-
-/*!
- \qmlproperty bool Mesh::dumpInfo
-
- Flag set to true if the description of the item will be dumped to the console.
-
- When this flag is true, useful debugging and diagnostic information, for example the
- names of all the subnodes of the mesh, materials and geometry parameters, will be
- dumped to the console during the loading of the model.
-*/
-bool QDeclarativeMesh::dumpInfo() const
-{
- return d->dumpInfo;
-}
-
-void QDeclarativeMesh::setDumpInfo(bool enable)
-{
- if (enable != d->dumpInfo)
- {
- d->dumpInfo = enable;
- emit dumpInfoChanged();
- }
-}
-
-/*!
- \internal
- Set the \a scene associated with this mesh.
-
- The function attempts to load a meaningful scene if one exists, and will attempt to
- locate the section of the scene to which this mesh applies based on mesh-name.
-
- Failure to find an appropriate scene will generate the warning messages.
-
- It should be noted that for successful operation of this function, the appropriate plugin
- file reader should be built and installed. Failure to do so will result in a warning and
- failure to display the scene.
-
- \sa QGLAbstractScene
-*/
-void QDeclarativeMesh::setScene(QGLAbstractScene *scene)
-{
- delete d->scene;
- resetSceneBranches();
- d->scene = scene;
- if (!d->scene) {
- qWarning("Could not load %s (possibly plugin could not be found)",
- d->data.toString().toLatin1().constData());
- }
- else {
- QGLSceneNode *insertObject;
- initSceneObjectList();
- if (d->meshName.isEmpty())
- insertObject = getSceneObject();
- else
- insertObject = getSceneObject(d->meshName);
- //check if we found a valid/useful object to use based on the node name,
- //otherwise just output a list of valid names
- if (!insertObject && !d->meshName.isEmpty()) {
- qWarning() << "could not find" << d->meshName << "available:"
- << getSceneObjectNames();
- } else if (!insertObject) {
- qWarning() << "could not find main object in scene!";
- }
- //in either case we still need to add an object to the scene, so if we fail
- //we simply add a null value to indicate that this object is non-drawable
- addSceneBranch(insertObject);
-
-#ifndef QT_NO_DEBUG_STREAM
- if (insertObject && d->dumpInfo)
- {
- QGLSceneNode *node = qobject_cast<QGLSceneNode*>(insertObject);
- if (node)
- qDumpScene(node);
- }
-#endif
- }
- emit dataChanged();
- d->loaded = true;
- if (d->completed)
- emit loaded();
-}
-
-/*!
- \internal
- When a scene has been deconstructed into several branches, each one being a separately
- manipulated sub-branch of the whole, the branches taken are identified numerically. This
- function returns the next scene branch ID number
-*/
-int QDeclarativeMesh::nextSceneBranchId() const
-{
- //Retrieve the next unused scene branch ID
- return d->nextSceneBranchId;
-}
-
-/*!
- \internal
- This function "prunes" a specific branch away from the main scene-tree/graph and adds it to the
- list of independent branches drawn by the mesh. This facilitates animation & picking of specific
- sub-branches of the larger tree.
-
- The user specifies a sceneobject/node \a nodeName, which will form the "root" of the new branch,
- as well as a \a parent to which this branch shall be attached. Normally the branch will simply
- be given the original scene as its parent, so that all standard object hierarchy manipulation/
- destruction rules apply, however this \a parent parameter gives the user extra flexibility if
- required.
-*/
-int QDeclarativeMesh::createSceneBranch(QString nodeName, QObject *parent)
-{
- if (!d->scene) {
- qWarning() << "Unable to split mesh: no scene initialised - attempt to add scene object failed.";
- return -1;
- }
- else {
- int branchId = nextSceneBranchId();
- QGLSceneNode *sceneNode = getSceneObject(nodeName);
-#ifndef QT_NO_DEBUG_STREAM
- if (d->dumpInfo)
- qDumpScene(sceneNode);
-#endif
- if (sceneNode) {
- QGLSceneNode *parentNode = qobject_cast<QGLSceneNode *>(sceneNode->parent());
- QObject *prevParent=parentNode;
- if (parentNode)
- parentNode->removeNode(sceneNode); //this becomes irrelevant.
-
- //sceneNode->setParent(d->scene); //TODO: currently this fails as sceneNode changes make problems.
- //If no specific parent is nominated, use the scene specified by the mesh
- parent ? sceneNode->setParent(parent) : sceneNode->setParent(d->scene);
- addSceneBranch(sceneNode, prevParent);
-
- return branchId;
- }
- else {
- qWarning() << "Warning: Unable to find node " << nodeName << " in given mesh. Available nodes:"
- << getSceneObjectNames();
- return -1;
- }
- }
-}
-
-/*!
- \internal
- Given a scene object \a rootSceneObject, this function adds a pointer to the object to an internally
- maintained map of scene branches.
-
- The \a previousParent of \a rootSceneObject is also stored so that the object can be restored to its
- previous parent if necessary.
-*/
-int QDeclarativeMesh::addSceneBranch(QGLSceneNode *rootSceneObject, QObject *previousParent)
-{
- //when adding a new object to a mesh we also store the previous parent information
- //in case we wish to 'reattach' it to the parent at a later stage.
- QDeclarativeMeshPrivate::branchObject newBranch;
- newBranch.previousParent=previousParent;
- newBranch.rootSceneObject = rootSceneObject;
-
- d->sceneBranches.insert(d->nextSceneBranchId, newBranch);
-
- return ++d->nextSceneBranchId;
-}
-
-/*!
- \internal
- When an object is deleted or the user otherwise calls this function, the scene branch identified by
- \a branchId is reattached to the parent node from which it was originally pruned.
-
- If a problem occurs or the parent node is undefined (eg. null), an attempt is made to reattach it instead
- to the primary/default scene object/node, which corresponds to item 0 in the map.
-
- If the item selected is already the default item, and no parent can be found, it is deleted.
-*/
-void QDeclarativeMesh::restoreSceneBranch(int branchId)
-{
-
- if (d->sceneBranches.contains(branchId)) {
- qWarning() <<"Mesh does not contain branch " << branchId<<". Ignoring.\n";
- return;
- }
-
- QDeclarativeMeshPrivate::branchObject targetBranch = d->sceneBranches.value(branchId);
-
- if (!targetBranch.previousParent && branchId!=0) {
- targetBranch.rootSceneObject->setParent(getSceneObject());
- }
- else if (!targetBranch.previousParent){
- qWarning() << "Unable to find a parent to reattach default scene object to. Skipping.";
- targetBranch.rootSceneObject->setParent(d->scene);
- } else {
- targetBranch.rootSceneObject->setParent(targetBranch.previousParent);
- }
-
- if (!d->sceneBranches.remove(branchId)) {
- qWarning() << "Unable to remove branch "<<branchId<<" from Mesh. Ignoring.";
- }
-}
-
-/*!
- \internal
- Return a pointer to the scene branch identified by \a branchId.
-*/
-QGLSceneNode *QDeclarativeMesh::getSceneBranch(int branchId) const
-{
- if (!d->sceneBranches.contains(branchId)) return NULL;
- QDeclarativeMeshPrivate::branchObject targetBranch = d->sceneBranches.value(branchId);
- return targetBranch.rootSceneObject;
-}
-
-
-/*!
- \internal
- This function iterates through the list of scene branches in the internal map and attempts to
- restore them to their original position in the object hierarchy of the scene. It then clears the
- map ready for reuse.
-*/
-void QDeclarativeMesh::resetSceneBranches()
-{
- //Delete all "hanging" object entries in the scene branches list and return them
- //to their rightful place in their parent scene if possible.
- for (int i=1; i<d->nextSceneBranchId; i++) {
- restoreSceneBranch(i);
- }
-
- d->sceneBranches.clear();
- d->nextSceneBranchId = 0;
-}
-
-/*!
- \internal
- Core "draw" function for the mesh draws scene branch \a branchId using \a painter.
-*/
-void QDeclarativeMesh::draw(QGLPainter *painter, int branchId)
-{
- if (!d->sceneBranches.contains(branchId)) {
- qWarning() << "No scene object with ID: " << branchId << "for" << this;
- } else {
- QDeclarativeMeshPrivate::branchObject targetBranch = d->sceneBranches.value(branchId);
- targetBranch.rootSceneObject->draw(painter);
- }
-}
-
-/*!
- \internal
- Reference counting increment.
-*/
-void QDeclarativeMesh::ref()
-{
- ++(d->refCount);
-}
-
-/*!
- \internal
- Reference counting decrement; returns true if there are still outstanding references
- to the class.
-*/
-bool QDeclarativeMesh::deref()
-{
- --(d->refCount);
- return d->refCount > 0;
-}
-
-
-/*!
- Assign the mesh the material \a materialName from the \l QGLMaterialCollection class,
- and bind to the node identified by \a nodeName.
-
- Returns a pointer to the QGLMaterial material object \a materialName; or NULL if
- either there is no current scene, or if the scene does not contain such a material.
-*/
-QObject *QDeclarativeMesh::material(const QString& nodeName, const QString& materialName)
-{
- if (!d->scene)
- return 0;
-
- QGLSceneNode *sceneObject;
-
- if (nodeName.isEmpty())
- sceneObject = getSceneObject();
- else
- sceneObject = getSceneObject(nodeName);
-
- if (!sceneObject || materialName.isEmpty()) {
- qWarning() << "Attempt to get material data " <<materialName << " from scene node "
- << nodeName <<" failed.";
- return NULL;
- }
-
- QGLSceneNode *node = qobject_cast<QGLSceneNode *>(sceneObject);
-
- QGLMaterialCollection *p = node->palette();
-
- QGLMaterial *params = p->material(materialName);
- if (params && !d->connected.contains(params)) {
- d->connected.append(params);
- connect(params, SIGNAL(materialChanged()), this, SIGNAL(dataChanged()));
- }
- return params;
-}
-
-/*!
- \internal
-*/
-void QDeclarativeMesh::classBegin()
-{
-}
-
-/*!
- \internal
- Checks that all loading and initialisation has been finished, and emits the loaded() signal if
- the component is complete.
-
- \sa loaded()
-*/
-void QDeclarativeMesh::componentComplete()
-{
- d->completed = true;
- if (d->loaded)
- {
- emit loaded();
- emit nodeChanged();
- emit dataChanged();
- }
-}
-
-/*!
- \qmlsignal Mesh::onLoaded()
-
- This handler is called when mesh loading is complete.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/quick3d/qdeclarativemesh.h b/src/quick3d/qdeclarativemesh.h
deleted file mode 100644
index d7eea5da..00000000
--- a/src/quick3d/qdeclarativemesh.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QDECLARATIVEMESH_H
-#define QDECLARATIVEMESH_H
-
-#include "qt3dquickglobal.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeparserstatus.h>
-
-#include "qglscenenode.h"
-#include "qglpainter.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(QtQuick3D)
-
-class QDeclarativeMeshPrivate;
-class QGLAbstractScene;
-class QGLMaterial;
-
-class Q_QT3D_QUICK_EXPORT QDeclarativeMesh : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY dataChanged)
- Q_PROPERTY(QString meshName READ meshName WRITE setMeshName NOTIFY dataChanged)
- Q_PROPERTY(QString options READ options WRITE setOptions NOTIFY optionsChanged)
- Q_PROPERTY(QGLSceneNode *node READ getSceneObject NOTIFY nodeChanged)
- Q_PROPERTY(bool dumpInfo READ dumpInfo WRITE setDumpInfo NOTIFY dumpInfoChanged)
-
-public:
- QDeclarativeMesh(QObject *parent = 0);
- ~QDeclarativeMesh();
-
- QUrl source() const;
- void setSource(const QUrl& value);
-
- QString meshName() const;
- void setMeshName(const QString& value);
-
- QString options() const;
- void setOptions(const QString &);
-
- bool dumpInfo() const;
- void setDumpInfo(bool);
-
- virtual void draw(QGLPainter *painter, int branchId);
-
- //The following functions relate to allocating the scene and its
- //respective objects, and acessing these nodes.
- void setScene(QGLAbstractScene *scene);
- void initSceneObjectList();
- QStringList getSceneObjectNames();
- QGLSceneNode *getSceneObject();
- QGLSceneNode *getSceneObject(const QString &name);
-
- //The following functions relate to splitting the main scene into sub-branches
- int nextSceneBranchId() const;
- int createSceneBranch(QString nodeName, QObject *parent = 0);
- int addSceneBranch(QGLSceneNode *rootSceneObject, QObject *previousParent=NULL);
- void restoreSceneBranch(int branchId);
- void resetSceneBranches();
- QGLSceneNode *getSceneBranch(int branchId) const;
-
- void ref();
- bool deref();
-
- Q_INVOKABLE QObject *material(const QString& nodeName, const QString& materialName);
-
- void classBegin();
- void componentComplete();
-
-
-Q_SIGNALS:
- void dataChanged();
- void loaded();
- void optionsChanged();
- void dumpInfoChanged();
- void nodeChanged();
-
-private Q_SLOTS:
- void dataRequestFinished();
-
-private:
- QDeclarativeMeshPrivate *d;
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeMesh)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick3d/qdeclarativeview3d.cpp b/src/quick3d/qdeclarativeview3d.cpp
deleted file mode 100644
index 26cd31f5..00000000
--- a/src/quick3d/qdeclarativeview3d.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qdeclarativeview3d.h"
-#include <QtOpenGL/QGLWidget>
-
-/*!
- \qmlclass QDeclarativeView3D
- \brief The QDeclarativeView3D replaces the QDeclarativeView for applications
- using OpenGL.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \section1 Usage
-
- This class is substituted for the QDeclarativeView class when creating
- Qt3D applications. It replaces the standard raster viewport with an OpenGL
- capable viewport suitable for rendering 3D content.
-*/
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
-*/
-QDeclarativeView3D::QDeclarativeView3D(QWidget *parent) : QDeclarativeView(parent)
-{
- //Set up the GL viewport widget format in the same manner that
- //qmlviewer does when openGL is specified.
- QGLFormat format = QGLFormat::defaultFormat();
-#ifdef Q_WS_MAC
- format.setSampleBuffers(true);
-#else
- format.setSampleBuffers(false);
-#endif
-
- //Assign a GLWidget as the viewport.
- defaultViewportWidget = new QGLWidget(format);
- setViewport(defaultViewportWidget);
-}
-
-/*!
- \internal
-*/
-QDeclarativeView3D::~QDeclarativeView3D()
-{
- if (defaultViewportWidget) delete defaultViewportWidget;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick3d/qdeclarativeview3d.h b/src/quick3d/qdeclarativeview3d.h
deleted file mode 100644
index 0ab65690..00000000
--- a/src/quick3d/qdeclarativeview3d.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QDECLARATIVEVIEW3D_H
-#define QDECLARATIVEVIEW3D_H
-
-#include <QtDeclarative/qdeclarativeview.h>
-#include "qt3dquickglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(QtQuick3D)
-
-class QGLWidget;
-
-class Q_QT3D_QUICK_EXPORT QDeclarativeView3D : public QDeclarativeView
-{
-public:
- QDeclarativeView3D(QWidget *parent = 0);
- ~QDeclarativeView3D();
-
-protected:
- QGLWidget *defaultViewportWidget;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick3d/qdeclarativeviewport.h b/src/quick3d/qdeclarativeviewport.h
deleted file mode 100644
index 8dc501aa..00000000
--- a/src/quick3d/qdeclarativeviewport.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QDECLARATIVEVIEWPORT_H
-#define QDECLARATIVEVIEWPORT_H
-
-#include "qt3dquickglobal.h"
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(QtQuick3D)
-
-class QDeclarativeItem3D;
-
-// Abstract interface for "Item3D" getting access to the "Viewport"
-// item in the QML/3D plugin.
-class Q_QT3D_QUICK_EXPORT QDeclarativeViewport
-{
-public:
- virtual int registerPickableObject(QObject *obj) = 0;
- virtual void update3d() = 0;
- virtual bool blending() const = 0;
-
- void setItemViewport(QDeclarativeItem3D *item);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/quick3d/qt3dquickglobal.h b/src/quick3d/qt3dquickglobal.h
deleted file mode 100644
index 1e14d3e7..00000000
--- a/src/quick3d/qt3dquickglobal.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QT3DQUICKGLOBAL_H
-#define QT3DQUICKGLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-QT_LICENSED_MODULE(QtQuick3D)
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
-# if defined(QT_NODLL)
-# undef QT_MAKEDLL
-# undef QT_DLL
-# elif defined(QT_MAKEDLL) /* create a Qt DLL library */
-# if defined(QT_DLL)
-# undef QT_DLL
-# endif
-# if defined(QT_BUILD_QT3D_QUICK_LIB)
-# define Q_QT3D_QUICK_EXPORT Q_DECL_EXPORT
-# else
-# define Q_QT3D_QUICK_EXPORT Q_DECL_IMPORT
-# endif
-# elif defined(QT_DLL) /* use a Qt DLL library */
-# define Q_QT3D_QUICK_EXPORT Q_DECL_IMPORT
-# endif
-#endif
-#if !defined(Q_QT3D_QUICK_EXPORT)
-# if defined(QT_SHARED)
-# define Q_QT3D_QUICK_EXPORT Q_DECL_EXPORT
-# else
-# define Q_QT3D_QUICK_EXPORT
-# endif
-#endif
-
-#endif
diff --git a/src/quick3d/quick3d.pri b/src/quick3d/quick3d.pri
deleted file mode 100644
index 97a637de..00000000
--- a/src/quick3d/quick3d.pri
+++ /dev/null
@@ -1,18 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- qt3dquickglobal.h \
- qdeclarativeitem3d.h \
- qdeclarativeeffect.h \
- qdeclarativemesh.h \
- qdeclarativeview3d.h \
- qdeclarativeviewport.h
-
-
-SOURCES += \
- qdeclarativeeffect.cpp \
- qdeclarativeitem3d.cpp \
- qdeclarativeview3d.cpp \
- qdeclarativemesh.cpp
-
diff --git a/src/quick3d/quick3d.pro b/src/quick3d/quick3d.pro
deleted file mode 100644
index d4b005f6..00000000
--- a/src/quick3d/quick3d.pro
+++ /dev/null
@@ -1,123 +0,0 @@
-TEMPLATE = lib
-TARGET = Qt3DQuick$${QT_LIBINFIX}
-gcov {
- CONFIG += staticlib warn_on
- QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
- QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
-} else {
- CONFIG += dll warn_on
-}
-
-QT += declarative
-
-include(../../pkg.pri)
-
-# See the README in the root dir re this code
-package {
- macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- LIBS += -framework Qt3D -F../threed
- INCLUDEPATH += ../threed/Qt3D.framework/Versions/1/Headers
- } else {
- win32 {
- CONFIG(debug, debug|release) {
- LIBS += ..\\threed\\debug\\Qt3Dd.lib
- } else {
- LIBS += ..\\threed\\release\\Qt3D.lib
- }
- } else {
- LIBS += -L../threed -lQt3D
- }
- INCLUDEPATH += ../../include/Qt3D
- }
- win32 {
- target.path = $$QT3D_INSTALL_BINS
- } else {
- target.path = $$QT3D_INSTALL_LIBS
- }
- INSTALLS += target
- QT += opengl network
-} else {
- CONFIG += qt3d
- DESTDIR = $$QT3D_INSTALL_LIBS
-}
-
-win32 {
- !static:DEFINES += QT_MAKEDLL
- package {
- installDll.path = $$QT3D_INSTALL_BINS
- installDll.files = $$DESTDIR_TARGET
- INSTALLS += installDll
- } else {
- DLLDESTDIR = $$QT3D_INSTALL_BINS
- }
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- }
-}
-
-symbian {
- DEFINES += QT_MAKEDLL
- CONFIG += epocallowdlldata
- MMP_RULES += EXPORTUNFROZEN
- LIBS += -lQt3D$${QT_LIBINFIX}
- TARGET.UID3 = 0x20031E96
- TARGET.CAPABILITY = All -Tcb
-}
-
-include(quick3d.pri)
-
-PUBLIC_HEADERS = $$HEADERS
-HEADERS += $$PRIVATE_HEADERS
-DEFINES += QT_BUILD_QT3D_QUICK_LIB
-
-!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
-
-package {
- distInstalls.files = $$PUBLIC_HEADERS
- distInstalls.path = $$QT3D_INSTALL_HEADERS/Qt3DQuick
- INSTALLS += distInstalls
-}
-
-# If Qt has been configured to build frameworks, then the build will put
-# the Qt3DQuick library into a framework bundle, so put the headers in the bundle
-# as well. Other OS's, or mac without frameworks, install the headers into
-# the Qt build tree directly.
-macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$DESTDIR/
- CONFIG += lib_bundle
- FRAMEWORK_HEADERS.version = Versions
- FRAMEWORK_HEADERS.path = Headers
- FRAMEWORK_HEADERS.files = $$PUBLIC_HEADERS
- QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
-} else {
- exportHeaders.input = PUBLIC_HEADERS
- package {
- # in the package case we need the headers for the actual build, the
- # distInstalls stanza above takes care of packaging the headers for the dev pkg
- exportHeaders.output = ../../include/Qt3DQuick/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- } else {
- !maemo: exportHeaders.output = $$[QT_INSTALL_HEADERS]/Qt3DQuick/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- }
- exportHeaders.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- exportHeaders.CONFIG += no_link_no_clean
- exportHeaders.variable_out = PRE_TARGETDEPS
- QMAKE_EXTRA_COMPILERS += exportHeaders
-}
-
-symbian {
- load(data_caging_paths)
-
- qt3dMwHeaders = *.h
- for(api,qt3dMwHeaders) {
- entries=$$files($$api);
- #files() attaches a ';' at the end which needs to be removed
- entries=$$replace(entries, ;,)
- for(entry,entries) {
- exists($$entry) {
- contains(PUBLIC_HEADERS, $$basename(entry)) {
- BLD_INF_RULES.prj_exports += "$$entry $$MW_LAYER_PUBLIC_EXPORT_PATH(Qt3DQuick/$$basename(entry))"
- }
- }
- }
- }
-}
diff --git a/src/scripts/LICENSE.LGPL.txt b/src/scripts/LICENSE.LGPL.txt
deleted file mode 100644
index 2db28fb5..00000000
--- a/src/scripts/LICENSE.LGPL.txt
+++ /dev/null
@@ -1,514 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
-
- The Qt GUI Toolkit is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- Contact: Nokia Corporation (qt-info@nokia.com)
-
- You may use, distribute and copy the Qt GUI Toolkit under the terms of
- GNU Lesser General Public License version 2.1, which is displayed below.
-
--------------------------------------------------------------------------
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/src/scripts/README b/src/scripts/README
deleted file mode 100644
index aa49d282..00000000
--- a/src/scripts/README
+++ /dev/null
@@ -1,39 +0,0 @@
-This directory contains miscellaneous utility scripts for use with Qt3D.
-
-filter-qmldump.pl
-=================
-
-Use this script to regenerate the library.xml files after making changes
-to the properties or structure of the QML bindings.
-
-It expects a file called "library.xml" to be in the current directory, and
-requires a single command line argument, which is a string matching the
-module name to filter on.
-
-Typical use:
-
-1) Build and install Qt3D into a given Qt at $QTDIR
-2) Ensure qmldump is available in your $PATH (see below)
-3) Run qmldump to generate the library.xml file:
- qmldump $QTDIR/imports Qt3D > library.xml
-4) Filter the output to just include the Qt3D module:
- filter-qmldump.pl Qt3D > library-qt3d.xml
-
-Repeat 3) & 4) for the Shapes library:
- qmldump $QTDIR/imports/Shapes Qt3D.Shapes > library.xml
- filter-qmldump.pl Qt3D > library-qt3d.xml
-
-To generate the plugins.qmltypes, you first need a qmldump binary generated from
-sources shipped with Qt Creator version less than 2.2. On Mac these are inside
-the app bundle, other platforms vary. If all else fails get the sources from the
-Qt Creator repo.
-
-To build qmldump you need access to private headers, so therefore it must be
-built against a source build of Qt. On Mac it is helpful to build qmldump with
-"qmake CONFIG-=app_bundle" so that you get a regular command-line binary.
-
-In the above note that $QTDIR points to the root of the Qt where Qt3D is installed.
-
-Check the contents of library.xml above and ensure it is XML - not yaml. If you
-see some curly braces { } - then the version of qmldump source you used was for
-Qt Creator > 2.2 - you somehow have the later version qmldump sources.
diff --git a/src/scripts/build_mac_package.sh b/src/scripts/build_mac_package.sh
deleted file mode 100755
index 39fbc387..00000000
--- a/src/scripts/build_mac_package.sh
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/bin/bash
-#############################################################################
-##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
-## Contact: Nokia Corporation (qt-info@nokia.com)
-##
-## This file is part of the QtQuick3D 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$
-##
-#############################################################################
-
-set -e
-
-APP=QtQuick3D
-
-PRO=quick3d.pro
-
-if [[ -z "$1" ]]; then
- echo "Usage: build_bundle.sh 1.2.3"
- echo "(where 1.2.3 is the version number)"
- exit 1;
-fi
-
-if [[ ! -f ./quick3d.pro ]]; then
- echo "Could not find quick3d.pro in current directory."
- echo "This script should be run from the root of a Qt3D source tree."
- exit 1;
-fi
-
-VER=$1
-
-echo "Building ${APP}..."
-qmake -makefile -spec macx-g++ -r CONFIG+=release CONFIG+=package quick3d.pro
-make $(JOBS)
-
-DIST=dist
-DEV=dev
-DEV_PKG_ROOT="$DIST/$DEV/Pkg_Root"
-mkdir -p $DEV_PKG_ROOT
-INSTALL_ROOT=$PWD/dist/dev/Pkg_Root make $(JOBS) install
-
-make docs
-DOC_LOC="Developer/Documentation/QtQuick3D"
-mkdir -p "$DEV_PKG_ROOT/$DOC_LOC"
-mv doc/html "$DEV_PKG_ROOT/$DOC_LOC"
-
-DEV_PKG_RES="$DIST/$DEV/Resources"
-mkdir -p $DEV_PKG_RES
-cp src/scripts/mac_installer_background.png $DEV_PKG_RES/background.png
-
-XMPL=examples
-XMPL_PKG_ROOT="$DIST/$XMPL/Pkg_Root"
-mkdir -p "$XMPL_PKG_ROOT"
-
-XMPL_PKG_RES="$DIST/$XMPL/Resources"
-mkdir -p $XMPL_PKG_RES
-cp src/scripts/mac_installer_background.png $XMPL_PKG_RES/background.png
-
-XMPL_LOC="Applications/QtQuick3D Examples"
-mkdir -p "${XMPL_PKG_ROOT}/$XMPL_LOC"
-mv "${DEV_PKG_ROOT}/Developer/Tools/Qt" "${XMPL_PKG_ROOT}/$XMPL_LOC"
-
-RELEASE_DIR="../${APP}-${VER}"
-mkdir -p "${RELEASE_DIR}"
-
-# http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/packagemaker.1.html
-# ...or see $PKGMKR -help for options
-# some useful tips at http://homepage.mac.com/simx/technonova/tips/packagemaker_and_installer.html
-# but a bit out of date - eg options now have --switch syntax and plist files are not used
-
-PKGMGR="/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
-
-## TODO: create VolumeCheck script to ensure 4.7.2 is installed
-PKG="${RELEASE_DIR}/${APP}-${VER}-${DEV}.pkg"
-$PKGMGR --root "$DEV_PKG_ROOT" \
- --id "com.nokia.qtquick3d.${DEV}" \
- --resources "$DEV_PKG_RES" \
- --title "Core Developer Tools" \
- --target 10.5 --version "$VER" --verbose --out "$PKG"
-
-PKG="${RELEASE_DIR}/${APP}-${VER}-${XMPL}.pkg"
-$PKGMGR --root "$XMPL_PKG_ROOT" \
- --id "com.nokia.qtquick3d.${XMPL}" \
- --resources "$XMPL_PKG_RES" \
- --title "Example Applications" \
- --target 10.5 --version "$VER" --verbose --out "$PKG"
-
-DMG="../${APP}-${VER}.dmg"
-
-echo "Placing packages into disk image"
-hdiutil create -srcfolder ${RELEASE_DIR} ${DMG}
-hdiutil internet-enable -yes ${DMG}
-
-echo "New distributable ready in ${DMG}"
diff --git a/src/scripts/build_src_package.sh b/src/scripts/build_src_package.sh
deleted file mode 100755
index 70d51884..00000000
--- a/src/scripts/build_src_package.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-#############################################################################
-##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
-## Contact: Nokia Corporation (qt-info@nokia.com)
-##
-## This file is part of the QtQuick3D 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$
-##
-#############################################################################
-
-
-usage() {
- cat <<USAGE
-usage:
- $0 <refspec> <version>
-
- Creates tar and zip source package from <refspec> and documentation-zip from current checkout.
- Run it from inside [a copy of] the git checkout of qt3d source.
-
- Generated package files and directories are named after <version>.
-
- Make sure the bin path for a valid Qt with qdoc3 is in the $PATH.
-
- example:
- env PATH=/path/to/Qt/bin:$PATH src/scripts/build_src_package.sh origin/tp1 1.0-tp1
-USAGE
- exit 1
-}
-
-## Command line parameters
-if [[ $# != 2 ]]; then
- usage;
-fi
-
-set -e
-
-QDOC3=$(qmake -query QT_INSTALL_BINS)/qdoc3
-
-echo "Using Qt ${QDOC3} to build doc"
-test -f quick3d.pro || usage
-
-BRANCH=$1
-VERSION=$2
-echo "Creating tar archive..."
-git archive --format=tar --prefix=qtquick3d-${VERSION}-src/ ${BRANCH} | gzip > ../qtquick3d-${VERSION}-src.tar.gz || exit 1
-echo "Creating zip archive..."
-git archive --format=zip --prefix=qtquick3d-${VERSION}-src/ ${BRANCH} > ../qtquick3d-${VERSION}-src.zip || exit 1
-echo "Creating documentation..."
-rm -r -f doc/html
-qmake quick3d.pro -spec macx-g++ CONFIG+=package >/dev/null || exit 1
-make docs || exit 1
-cd doc
-cp -r html qtquick3d-${VERSION}
-zip -r ../../qtquick3d-${VERSION}-doc.zip qtquick3d-${VERSION} >/dev/null
-rm -r qtquick3d-${VERSION}
diff --git a/src/scripts/build_win_package.bat b/src/scripts/build_win_package.bat
deleted file mode 100644
index f428d2e1..00000000
--- a/src/scripts/build_win_package.bat
+++ /dev/null
@@ -1,88 +0,0 @@
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-::
-:: Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-:: All rights reserved.
-:: Contact: Nokia Corporation (qt-info@nokia.com)
-::
-:: This file is part of the FOO 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$
-::
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-::
-:: Before running this script ensure that the %PATH% has the location of:
-:: - the correct qmake for the Qt to build against
-:: - the compiler and build tools, eg nmake
-:: for these first two, use the C:\Qt\<ver>\bin\qtvars.bat vsvars command
-:: - NSIS compiler, "makensis"
-:: set PATH=%PATH%;"C:\Program Files (x86)\NSIS"
-:: NSIS needs the custom license plugin - if its not installed get it
-:: from http://nsis.sourceforge.net/CustomLicense_plug-in
-:: Run this script from the root of a complete source tree of Qt3D, eg
-:: mkdir C:\build\qt
-:: cd C:\build\qt
-:: mkdir quick3d_mk_win_pkg
-:: echo .git >exclude
-:: xcopy /EXCLUDE:exclude /S C:\depot\qt\quick3d quick3d_mk_win_pkg
-:: cd quick3d_mk_win_pkg
-:: Use jom if possible - put jom in the path if you want faster compiles
-:: set PATH=%PATH%;C:\QtSDK\QtCreator\bin
-:: src\scripts\build_win_package.bat
-
-where jom.exe
-if %ERRORLEVEL% NEQ 0 (
- SET MAKE_PRG=nmake
-) else (
- SET MAKE_PRG=jom
-)
-
-mkdir tmp
-
-qmake -query QT_VERSION >tmp\qt_version
-set /P QT_VERSION= <tmp\qt_version
-
-qmake -query QT_INSTALL_PREFIX >tmp\qt_prefix
-set /P QT_PREFIX= <tmp\qt_prefix
-set QT_PREFIX_PATH=%QT_PREFIX:~2%
-
-:: On windows if the qt3d.prf and qt3dquick.prf exist in the Qt, the build will fail
-:: with impenetrable link errors. This should not happen but might if you are trying
-:: to debug the installer scripts, and do something odd.
-del %QTDIR%\mkspecs\features\qt3d*
-
-qmake.exe quick3d.pro -spec win32-msvc2008 CONFIG+=release CONFIG+=package
-
-:: This has to be the full path, but without the drive letter...
-set INSTALL_ROOT=%CD:~2%\tmp
-%MAKE_PRG% install
-%MAKE_PRG% docs
-makensis /DQT_VERSION=%QT_VERSION% /DQT_PREFIX_PATH=%QT_PREFIX_PATH% /NOCD src\scripts\build_win_package.nsi
diff --git a/src/scripts/build_win_package.nsi b/src/scripts/build_win_package.nsi
deleted file mode 100644
index b20f4add..00000000
--- a/src/scripts/build_win_package.nsi
+++ /dev/null
@@ -1,218 +0,0 @@
-!include LogicLib.nsh
-!include nsDialogs.nsh
-
-!define PRODUCT_NAME "QtQuick3D"
-!define PRODUCT_VERSION "1.0-tp1"
-!define PRODUCT_PUBLISHER "Nokia"
-!define PRODUCT_WEB_SITE "http://doc.qt.nokia.com/qt-quick3d-snapshot/"
-!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\qglinfo.exe"
-!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_ROOT_KEY "HKLM"
-
-; MUI 1.67 compatible ------
-!include "MUI.nsh"
-
-; MUI Settings
-!define MUI_ABORTWARNING
-!define MUI_ICON "src\scripts\qtquick3d.ico"
-!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
-!define MUI_WELCOMEFINISHPAGE_BITMAP "src\scripts\win_installer_background.bmp"
-!define MUI_WELCOMEPAGE_TITLE "${PRODUCT_NAME} Setup"
-!define MUI_WELCOMEPAGE_TEXT "${PRODUCT_NAME} will be installed into Qt ${QT_VERSION}, found in $INSTDIR. If you do not want ${PRODUCT_NAME} installed there, click cancel below."
-
-; Welcome page
-!insertmacro MUI_PAGE_WELCOME
-; License page
-!insertmacro MUI_PAGE_LICENSE "src\scripts\LICENSE.LGPL.txt"
-; Directory page
-; Disable this since we only install where we detect the right Qt
-; !insertmacro MUI_PAGE_DIRECTORY
-; Instfiles page
-!insertmacro MUI_PAGE_INSTFILES
-!define MUI_FINISHPAGE_NOAUTOCLOSE
-; Finish page
-Page custom DisplayWelcomeMessage
-!define MUI_FINISHPAGE_RUN $INSTDIR\quick3d\bin\run_start_program.bat
-!define MUI_FINISHPAGE_RUN_TEXT "Run QtQuick3D QGLInfo program"
-!define MUI_FINISHPAGE_LINK "QtQuick3D documentation"
-!define MUI_FINISHPAGE_LINK_LOCATION $INSTDIR\quick3d\doc\html\index.html
-
-!insertmacro MUI_PAGE_FINISH
-
-; Uninstaller pages
-!insertmacro MUI_UNPAGE_INSTFILES
-
-; Language files
-!insertmacro MUI_LANGUAGE "English"
-
-; MUI end ------
-
-; Where make install puts all the files
-!define MK_INST_ROOT tmp
-
-Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
-InstallDir "$PROGRAMFILES\Qt\${PRODUCT_VERSION}\quick3d"
-InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
-ShowInstDetails show
-ShowUnInstDetails show
-
-; HKCU\Software\Trolltech\Versions\DefaultQtVersion REG_SZ "${QT_VERSION}"
-; HKCU\Software\Trolltech\Versions\${QT_VERSION}\InstallDir REG_SZ "C:\Qt\${QT_VERSION}"
-
-Function .onInit
- LogSet on
- ReadRegStr $0 HKCU "Software\Trolltech\Versions\${QT_VERSION}" "InstallDir"
- ${If} $0 == ""
- MessageBox MB_ICONEXCLAMATION "Please install Qt v${QT_VERSION} MSVC from http:\\qt.nokia.com\downloads before installing ${PRODUCT_NAME} ${PRODUCT_VERSION}"
- Abort
- ${EndIf}
- StrCpy $INSTDIR $0
-FunctionEnd
-
-Function DisplayWelcomeMessage
- ; Create the temporary plugins directory
- InitPluginsDir
-
- ; Put the welcome message in the temporary plugins directory.
- ; The plugins directory is deleted when the installer quits.
- File "/oname=$PLUGINSDIR\windows-install.txt" "src\scripts\windows-install.txt"
-
- nsDialogs::Create 1018
- Pop $0
-
- nsDialogs::CreateControl /NOUNLOAD ${__NSD_Text_CLASS} ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_MULTILINE} ${__NSD_Text_EXSTYLE} 20 45 325 200 ''
- Pop $1
-
- CustomLicense::LoadFile "$PLUGINSDIR\windows-install.txt" $1
- nsDialogs::Show
-
-FunctionEnd
-
-Section "MainSection" SEC01
- SetOverwrite try
- CreateDirectory "$SMPROGRAMS\QtQuick3D"
- CreateDirectory "$SMPROGRAMS\QtQuick3D\Examples"
- CreateDirectory "$SMPROGRAMS\QtQuick3D\Demos"
-
- ; For the CreateShortCut command, the outpath is actually used for the working directory.
- ; By setting $INSTDIR\bin to the working directory all these lnk targets should be able
- ; to find their dependent dll's without needing to set the path
- SetOutPath "$INSTDIR\bin"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\QtQuick3D.lnk" "$INSTDIR\quick3d\bin\qglinfo.exe"
- CreateShortCut "$DESKTOP\QtQuick3D.lnk" "$INSTDIR\quick3d\bin\qglinfo.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Basket.lnk" "$INSTDIR\quick3d\bin\basket_qml.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Cube.lnk" "$INSTDIR\quick3d\bin\cube_qml.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Forest.lnk" "$INSTDIR\quick3d\bin\forest_qml.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Lander.lnk" "$INSTDIR\quick3d\bin\lander.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Matrix Animation.lnk" "$INSTDIR\quick3d\bin\matrix_animation.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Monkey God.lnk" "$INSTDIR\quick3d\bin\monkeygod.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Moon.lnk" "$INSTDIR\quick3d\bin\moon.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Photo Room.lnk" "$INSTDIR\quick3d\bin\photoroom.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Shaders.lnk" "$INSTDIR\quick3d\bin\shaders.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Sphere.lnk" "$INSTDIR\quick3d\bin\sphere.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Teapot.lnk" "$INSTDIR\quick3d\bin\teapot_qml.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Teapot Bounce.lnk" "$INSTDIR\quick3d\bin\teapot_bounce_qml.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Basket (C++).lnk" "$INSTDIR\quick3d\bin\basket.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Builder.lnk" "$INSTDIR\quick3d\bin\builder.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Cube (C++).lnk" "$INSTDIR\quick3d\bin\cube.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Cylinder.lnk" "$INSTDIR\quick3d\bin\cylinder.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Geometry.lnk" "$INSTDIR\quick3d\bin\geometry.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Graphicsview.lnk" "$INSTDIR\quick3d\bin\graphicsview.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Nesting.lnk" "$INSTDIR\quick3d\bin\nesting.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Tank.lnk" "$INSTDIR\quick3d\bin\tank.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Examples\Teapot (C++).lnk" "$INSTDIR\quick3d\bin\teapot.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Model Viewer.lnk" "$INSTDIR\quick3d\bin\model_viewer.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Robo Bounce.lnk" "$INSTDIR\quick3d\bin\robo_bounce.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Tea Service.lnk" "$INSTDIR\quick3d\bin\tea_service.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Cube House.lnk" "$INSTDIR\quick3d\bin\cubehouse.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Page Flip.lnk" "$INSTDIR\quick3d\bin\pageflip.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Photo-browser 3D.lnk" "$INSTDIR\quick3d\bin\photobrowser3d.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Shapes.lnk" "$INSTDIR\quick3d\bin\shapes.exe"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Demos\Tea Service (C++).lnk" "$INSTDIR\quick3d\bin\teaservice.exe"
-
- ; bin imports include lib mkspecs plugins quick3d
- SetOutPath "$INSTDIR\quick3d\bin"
- File "${MK_INST_ROOT}${QT_PREFIX_PATH}\bin\*.exe"
- File /r "${MK_INST_ROOT}${QT_PREFIX_PATH}\quick3d\resources"
- SetOutPath "$INSTDIR\lib"
- File "${MK_INST_ROOT}${QT_PREFIX_PATH}\bin\*.lib"
- SetOutPath "$INSTDIR\quick3d\doc"
- File /r "doc\html"
- SetOutPath "$INSTDIR\bin"
- File "${MK_INST_ROOT}${QT_PREFIX_PATH}\bin\*.dll"
- SetOutPath "$INSTDIR"
- File /r "${MK_INST_ROOT}${QT_PREFIX_PATH}\imports"
- File /r "${MK_INST_ROOT}${QT_PREFIX_PATH}\include"
- File /r "${MK_INST_ROOT}${QT_PREFIX_PATH}\mkspecs"
- File /r "${MK_INST_ROOT}${QT_PREFIX_PATH}\plugins"
-
- ClearErrors
- FileOpen $0 $INSTDIR\quick3d\bin\run_start_program.bat w
- IfErrors done
- FileWrite $0 "start /D $INSTDIR\bin $INSTDIR\quick3d\bin\qglinfo.exe"
- FileClose $0
- done:
-SectionEnd
-
-Section -AdditionalIcons
- SetOutPath $INSTDIR
- WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
- CreateShortCut "$SMPROGRAMS\QtQuick3D\Uninstall.lnk" "$INSTDIR\quick3d\uninst.exe"
-SectionEnd
-
-Section -Post
- WriteUninstaller "$INSTDIR\quick3d\uninst.exe"
- WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\quick3d\bin\qglinfo.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\quick3d\uninst.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\quick3d\bin\qglinfo.exe"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
- WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallRoot" "$INSTDIR"
-SectionEnd
-
-
-Function un.onUninstSuccess
- HideWindow
- MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
-FunctionEnd
-
-Function un.onInit
- ; LogSet on
- ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallRoot"
- StrCpy $INSTDIR $0
- MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
- Abort
-FunctionEnd
-
-Section Uninstall
- Delete "$INSTDIR\${PRODUCT_NAME}.url"
- Delete "$INSTDIR\quick3d\uninst.exe"
- RMDir /r "$INSTDIR\plugins\sceneformats"
- Delete "$INSTDIR\plugins\imageformats\qtga4.dll"
- Delete "$INSTDIR\mkspecs\features\qt3dquick.prf"
- Delete "$INSTDIR\mkspecs\features\qt3d.prf"
- Delete "$INSTDIR\lib\Qt3DQuick.*"
- Delete "$INSTDIR\lib\Qt3DQuickd.*"
- Delete "$INSTDIR\lib\Qt3D.*"
- Delete "$INSTDIR\lib\Qt3Dd.*"
- Delete "$INSTDIR\bin\Qt3DQuick.*"
- Delete "$INSTDIR\bin\Qt3DQuickd.*"
- Delete "$INSTDIR\bin\Qt3D.*"
- Delete "$INSTDIR\bin\Qt3Dd.*"
- RMDir /r "$INSTDIR\include\Qt3D"
- RMDir /r "$INSTDIR\include\Qt3DQuick"
- RMDir /r "$INSTDIR\imports\Qt3D"
- RMDir /r "$INSTDIR\quick3d"
-
- Delete "$DESKTOP\QtQuick3D.lnk"
- RMDir /r "$SMPROGRAMS\QtQuick3D"
- RMDir /r "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\QtQuick3D"
-
- DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
- DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
- SetAutoClose true
-SectionEnd
diff --git a/src/scripts/filter-qmldump.pl b/src/scripts/filter-qmldump.pl
deleted file mode 100755
index 84686898..00000000
--- a/src/scripts/filter-qmldump.pl
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
-## Contact: Nokia Corporation (qt-info@nokia.com)
-##
-## This file is part of the QtQuick3D 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$
-##
-#############################################################################
-
-use strict;
-use warnings;
-
-use XML::XPath;
-use XML::XPath::XMLParser;
-
-my $mod = shift or die "Usage: filter-qmldump.pl <module name>\n";
-
-warn "Filtering for modules in $mod\n";
-
-my $xp = XML::XPath->new(filename => 'library.xml');
-
-my $nodeset = $xp->find("//type/exports/export[\@module=\'$mod\']/../..");
-
-print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-print "<module>\n";
-
-foreach my $node ($nodeset->get_nodelist)
-{
- print " " . XML::XPath::XMLParser::as_string($node) . "\n";
-}
-
-print "<\\module>\n";
diff --git a/src/scripts/mac-install.rtf b/src/scripts/mac-install.rtf
deleted file mode 100644
index f596b71c..00000000
--- a/src/scripts/mac-install.rtf
+++ /dev/null
@@ -1,13 +0,0 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\paperw11900\paperh16840\vieww12000\viewh15840\viewkind0
-\deftab720
-\pard\pardeftab720\sl276\slmult1\sa200\ql\qnatural
-
-\f0\b\fs22 \cf0 Thanks for installing QtQuick3D! \
-
-\b0 To create applications with QtQuick3D simply open QtCreator, and ensure that your new project uses the "Qt in Path" under the "Auto-detected" section of the Qt Versions. See the Qt Creator's Preference pane and choose the "Qt 4" tab.\
-You can also compile applications from the command line by using the command "quake".\
-\
-} \ No newline at end of file
diff --git a/src/scripts/mac_installer_background.png b/src/scripts/mac_installer_background.png
deleted file mode 100644
index 0f2de686..00000000
--- a/src/scripts/mac_installer_background.png
+++ /dev/null
Binary files differ
diff --git a/src/scripts/qtquick3d.ico b/src/scripts/qtquick3d.ico
deleted file mode 100644
index b3b85e37..00000000
--- a/src/scripts/qtquick3d.ico
+++ /dev/null
Binary files differ
diff --git a/src/scripts/win_installer_background.bmp b/src/scripts/win_installer_background.bmp
deleted file mode 100644
index 785c943d..00000000
--- a/src/scripts/win_installer_background.bmp
+++ /dev/null
Binary files differ
diff --git a/src/scripts/windows-install.rtf b/src/scripts/windows-install.rtf
deleted file mode 100644
index e9c5f43d..00000000
--- a/src/scripts/windows-install.rtf
+++ /dev/null
Binary files differ
diff --git a/src/scripts/windows-install.txt b/src/scripts/windows-install.txt
deleted file mode 100644
index 909b0372..00000000
--- a/src/scripts/windows-install.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Thanks for installing QtQuick3D!
-
-To create applications with QtQuick3D
-simply open QtCreator, and ensure that
-your new project uses the Qt installed
-at C:\Qt\4.7.3.
-
-You can also compile applications from
-the command line by using the Start Menu
-item : "Qt 4.7.3 Command Prompt".
diff --git a/src/src.pro b/src/src.pro
deleted file mode 100644
index 48385ea6..00000000
--- a/src/src.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-CONFIG += ordered
-SUBDIRS = threed quick3d imports
-SUBDIRS += plugins
diff --git a/src/threed/api/api.pri b/src/threed/api/api.pri
deleted file mode 100644
index 6b06b650..00000000
--- a/src/threed/api/api.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += api/qopenglfunctions.h
-SOURCES += qopenglfunctions.cpp
diff --git a/src/threed/api/gl-funcs.txt b/src/threed/api/gl-funcs.txt
deleted file mode 100644
index 6bef6ce4..00000000
--- a/src/threed/api/gl-funcs.txt
+++ /dev/null
@@ -1,858 +0,0 @@
-void glActiveTexture(GLenum texture);
- inline es1, es2
- alt_name glActiveTextureARB
-
-void glAttachShader(GLuint program, GLuint shader);
- shader_only yes
- inline es2
- alt_name glAttachObjectARB
-
-void glBindAttribLocation(GLuint program, GLuint index, const char* name);
- shader_only yes
- inline es2
- alt_name glBindAttribLocationARB
-
-void glBindBuffer(GLenum target, GLuint buffer);
- inline es1, es2
-
-void glBindFramebuffer(GLenum target, GLuint framebuffer);
- inline es2
-
-void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
- inline es2
-
-void glBindTexture(GLenum target, GLuint texture);
- inline all
-
-void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
- inline es2
-
-void glBlendEquation( GLenum mode );
- inline es2
-
-void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
- inline es2
-
-void glBlendFunc(GLenum sfactor, GLenum dfactor);
- inline all
-
-void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
- inline es2
-
-void glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
- inline es1, es2
-
-void glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
- inline es1, es2
-
-GLenum glCheckFramebufferStatus(GLenum target);
- inline es2
-
-void glClear(GLbitfield mask);
- inline all
-
-void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
- inline all
-
-void glClearDepth(GLclampf depth);
- inline all_diff
- es_name glClearDepthf
-
-void glClearStencil(GLint s);
- inline all
-
-void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
- inline all
-
-void glCompileShader(GLuint shader);
- shader_only yes
- inline es2
- alt_name glCompileShader
-
-void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
- inline es1, es2
-
-void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
- inline es1, es2
-
-void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
- inline all
-
-void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
- inline all
-
-GLuint glCreateProgram(void);
- shader_only yes
- inline es2
- alt_name glCreateProgramObjectARB
-
-GLuint glCreateShader(GLenum type);
- shader_only yes
- inline es2
- alt_name glCreateShaderObjectARB
-
-void glCullFace(GLenum mode);
- inline all
-
-void glDeleteBuffers(GLsizei n, const GLuint* buffers);
- inline es1, es2
-
-void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
- inline es2
-
-void glDeleteProgram(GLuint program);
- shader_only yes
- inline es2
- alt_name glDeleteObjectARB
-
-void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
- inline es2
-
-void glDeleteShader(GLuint shader);
- shader_only yes
- inline es2
- alt_name glDeleteObjectARB
-
-void glDeleteTextures(GLsizei n, const GLuint* textures);
- inline all
-
-void glDepthFunc(GLenum func);
- inline all
-
-void glDepthMask(GLboolean flag);
- inline all
-
-void glDepthRange(GLclampf zNear, GLclampf zFar);
- inline all_diff
- es_name glDepthRangef
-
-void glDetachShader(GLuint program, GLuint shader);
- shader_only yes
- inline es2
- alt_name glDetachObjectARB
-
-void glDisable(GLenum cap);
- inline all
-
-void glDisableVertexAttribArray(GLuint index);
- shader_only yes
- inline es2
- alt_name glDisableVertexAttribArrayARB
-
-void glDrawArrays(GLenum mode, GLint first, GLsizei count);
- inline all
-
-void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices);
- inline all
-
-void glEnable(GLenum cap);
- inline all
-
-void glEnableVertexAttribArray(GLuint index);
- shader_only yes
- inline es2
- alt_name glEnableVertexAttribArrayARB
-
-void glFinish(void);
- inline all
-
-void glFlush(void);
- inline all
-
-void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
- inline es2
-
-void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
- inline es2
-
-void glFrontFace(GLenum mode);
- inline all
-
-void glGenBuffers(GLsizei n, GLuint* buffers);
- inline es1, es2
-
-void glGenerateMipmap(GLenum target);
- inline es2
-
-void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
- inline es2
-
-void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
- inline es2
-
-void glGenTextures(GLsizei n, GLuint* textures);
- inline all
-
-void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- shader_only yes
- inline es2
- alt_name glGetActiveAttribARB
-
-void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- shader_only yes
- inline es2
- alt_name glGetActiveUniformARB
-
-void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
- shader_only yes
- inline es2
- alt_name glGetAttachedObjectsARB
-
-int glGetAttribLocation(GLuint program, const char* name);
- shader_only yes
- inline es2
- alt_name glGetAttribLocationARB
-
-void glGetBooleanv(GLenum pname, GLboolean* params);
- inline all
-
-void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
- inline es2
-
-GLenum glGetError(void);
- inline all
-
-void glGetFloatv(GLenum pname, GLfloat* params);
- inline all
-
-void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
- inline es2
-
-void glGetIntegerv(GLenum pname, GLint* params);
- inline all
-
-void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
- shader_only yes
- inline es2
- alt_name glGetObjectParameterivARB
-
-void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
- shader_only yes
- inline es2
- alt_name glGetInfoLogARB
-
-void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
- inline es2
-
-void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
- shader_only yes
- inline es2
- alt_name glGetObjectParameterivARB
-
-void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
- shader_only yes
- inline es2
- alt_name glGetInfoLogARB
-
-void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
- shader_only yes
- inline es2
- special_handling yes
-
-void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
- shader_only yes
- inline es2
- alt_name glGetShaderSourceARB
-
-const GLubyte* glGetString(GLenum name);
- inline all
-
-void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
- inline all
-
-void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
- inline all
-
-void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
- shader_only yes
- inline es2
- alt_name glGetUniformfvARB
-
-void glGetUniformiv(GLuint program, GLint location, GLint* params);
- shader_only yes
- inline es2
- alt_name glGetUniformivARB
-
-int glGetUniformLocation(GLuint program, const char* name);
- shader_only yes
- inline es2
- alt_name glGetUniformLocationARB
-
-void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
- shader_only yes
- inline es2
- alt_name glGetVertexAttribfvARB
-
-void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
- shader_only yes
- inline es2
- alt_name glGetVertexAttribivARB
-
-void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer);
- shader_only yes
- inline es2
- alt_name glGetVertexAttribPointervARB
-
-void glHint(GLenum target, GLenum mode);
- inline all
-
-GLboolean glIsBuffer(GLuint buffer);
- inline es1, es2
-
-GLboolean glIsEnabled(GLenum cap);
- inline all
-
-GLboolean glIsFramebuffer(GLuint framebuffer);
- inline es2
-
-GLboolean glIsProgram(GLuint program);
- shader_only yes
- inline es2
- alt_name glIsProgramARB
- special_handling yes
-
-GLboolean glIsRenderbuffer(GLuint renderbuffer);
- inline es2
-
-GLboolean glIsShader(GLuint shader);
- shader_only yes
- inline es2
- alt_name glIsShaderARB
- special_handling yes
-
-GLboolean glIsTexture(GLuint texture);
- inline all
-
-void glLineWidth(GLfloat width);
- inline all
-
-void glLinkProgram(GLuint program);
- shader_only yes
- inline es2
- alt_name glLinkProgramARB
-
-void glPixelStorei(GLenum pname, GLint param);
- inline all
-
-void glPolygonOffset(GLfloat factor, GLfloat units);
- inline all
-
-void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
- inline all
-
-void glReleaseShaderCompiler(void);
- shader_only yes
- inline es2
- alt_name glReleaseShaderCompilerARB
- special_handling yes
-
-void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
- inline es2
-
-void glSampleCoverage(GLclampf value, GLboolean invert);
- inline es1, es2
-
-void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
- inline all
-
-void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
- shader_only yes
- inline es2
- alt_name glShaderBinaryARB
-
-void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length);
- shader_only yes
- inline es2
- alt_name glShaderSourceARB
-
-void glStencilFunc(GLenum func, GLint ref, GLuint mask);
- inline all
-
-void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
- inline es2
-
-void glStencilMask(GLuint mask);
- inline all
-
-void glStencilMaskSeparate(GLenum face, GLuint mask);
- inline es2
-
-void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
- inline all
-
-void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
- inline es2
-
-void glTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);
- inline all
-
-void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
- inline all
-
-void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
- inline all
-
-void glTexParameteri(GLenum target, GLenum pname, GLint param);
- inline all
-
-void glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
- inline all
-
-void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
- inline all
-
-void glUniform1f(GLint location, GLfloat x);
- shader_only yes
- inline es2
- alt_name glUniform1fARB
-
-void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
- shader_only yes
- inline es2
- alt_name glUniform1fvARB
-
-void glUniform1i(GLint location, GLint x);
- shader_only yes
- inline es2
- alt_name glUniform1iARB
-
-void glUniform1iv(GLint location, GLsizei count, const GLint* v);
- shader_only yes
- inline es2
- alt_name glUniform1ivARB
-
-void glUniform2f(GLint location, GLfloat x, GLfloat y);
- shader_only yes
- inline es2
- alt_name glUniform2fARB
-
-void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
- shader_only yes
- inline es2
- alt_name glUniform2fvARB
-
-void glUniform2i(GLint location, GLint x, GLint y);
- shader_only yes
- inline es2
- alt_name glUniform2iARB
-
-void glUniform2iv(GLint location, GLsizei count, const GLint* v);
- shader_only yes
- inline es2
- alt_name glUniform2ivARB
-
-void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
- shader_only yes
- inline es2
- alt_name glUniform3fARB
-
-void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
- shader_only yes
- inline es2
- alt_name glUniform3fvARB
-
-void glUniform3i(GLint location, GLint x, GLint y, GLint z);
- shader_only yes
- inline es2
- alt_name glUniform3iARB
-
-void glUniform3iv(GLint location, GLsizei count, const GLint* v);
- shader_only yes
- inline es2
- alt_name glUniform3ivARB
-
-void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- shader_only yes
- inline es2
- alt_name glUniform4fARB
-
-void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
- shader_only yes
- inline es2
- alt_name glUniform4fvARB
-
-void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
- shader_only yes
- inline es2
- alt_name glUniform4iARB
-
-void glUniform4iv(GLint location, GLsizei count, const GLint* v);
- shader_only yes
- inline es2
- alt_name glUniform4ivARB
-
-void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- shader_only yes
- inline es2
- alt_name glUniformMatrix2fvARB
-
-void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- shader_only yes
- inline es2
- alt_name glUniformMatrix3fvARB
-
-void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- shader_only yes
- inline es2
- alt_name glUniformMatrix4fvARB
-
-void glUseProgram(GLuint program);
- shader_only yes
- inline es2
- alt_name glUseProgramObjectARB
-
-void glValidateProgram(GLuint program);
- shader_only yes
- inline es2
- alt_name glValidateProgramARB
-
-void glVertexAttrib1f(GLuint indx, GLfloat x);
- shader_only yes
- inline es2
- alt_name glVertexAttrib1fARB
-
-void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
- shader_only yes
- inline es2
- alt_name glVertexAttrib1fvARB
-
-void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
- shader_only yes
- inline es2
- alt_name glVertexAttrib2fARB
-
-void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
- shader_only yes
- inline es2
- alt_name glVertexAttrib2fvARB
-
-void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
- shader_only yes
- inline es2
- alt_name glVertexAttrib3fARB
-
-void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
- shader_only yes
- inline es2
- alt_name glVertexAttrib3fvARB
-
-void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- shader_only yes
- inline es2
- alt_name glVertexAttrib4fARB
-
-void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
- shader_only yes
- inline es2
- alt_name glVertexAttrib4fvARB
-
-void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
- shader_only yes
- inline es2
- alt_name glVertexAttribPointerARB
-
-void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
- inline all
-
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALPHA 0x1906
-#define GL_ALPHA_BITS 0x0D55
-#define GL_ALWAYS 0x0207
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_BACK 0x0405
-#define GL_BLEND 0x0BE2
-#define GL_BLEND_COLOR 0x8005
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_BLEND_EQUATION_RGB 0x8009
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLUE_BITS 0x0D54
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_BYTE 0x1400
-#define GL_CCW 0x0901
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_CW 0x0900
-#define GL_DECR 0x1E03
-#define GL_DECR_WRAP 0x8508
-#define GL_DELETE_STATUS 0x8B80
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_DEPTH_BITS 0x0D56
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DITHER 0x0BD0
-#define GL_DONT_CARE 0x1100
-#define GL_DST_ALPHA 0x0304
-#define GL_DST_COLOR 0x0306
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_EQUAL 0x0202
-#define GL_EXTENSIONS 0x1F03
-#define GL_FALSE 0
-#define GL_FASTEST 0x1101
-#define GL_FIXED 0x140C
-#define GL_FLOAT 0x1406
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#define GL_FRONT 0x0404
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_FRONT_FACE 0x0B46
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-#define GL_GEQUAL 0x0206
-#define GL_GREATER 0x0204
-#define GL_GREEN_BITS 0x0D53
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_HIGH_INT 0x8DF5
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_INCR 0x1E02
-#define GL_INCR_WRAP 0x8507
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_INT 0x1404
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#define GL_INVALID_OPERATION 0x0502
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVERT 0x150A
-#define GL_KEEP 0x1E00
-#define GL_LEQUAL 0x0203
-#define GL_LESS 0x0201
-#define GL_LINEAR 0x2601
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_LINE_LOOP 0x0002
-#define GL_LINES 0x0001
-#define GL_LINE_STRIP 0x0003
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINK_STATUS 0x8B82
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_LOW_INT 0x8DF3
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE_ALPHA 0x190A
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_NEAREST 0x2600
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_NEVER 0x0200
-#define GL_NICEST 0x1102
-#define GL_NO_ERROR 0
-#define GL_NONE 0
-#define GL_NOTEQUAL 0x0205
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-#define GL_ONE 1
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_OUT_OF_MEMORY 0x0505
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_POINTS 0x0000
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_RED_BITS 0x0D52
-#define GL_RENDERBUFFER 0x8D41
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERER 0x1F01
-#define GL_REPEAT 0x2901
-#define GL_REPLACE 0x1E01
-#define GL_RGB 0x1907
-#define GL_RGB565 0x8D62
-#define GL_RGB5_A1 0x8057
-#define GL_RGBA 0x1908
-#define GL_RGBA4 0x8056
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLES 0x80A9
-#define GL_SCISSOR_BOX 0x0C10
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#define GL_SHADER_COMPILER 0x8DFA
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_SHORT 0x1402
-#define GL_SRC_ALPHA 0x0302
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_SRC_COLOR 0x0300
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_STENCIL_BITS 0x0D57
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_INDEX 0x1901
-#define GL_STENCIL_INDEX8 0x8D48
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STREAM_DRAW 0x88E0
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE 0x1702
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE31 0x84DF
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRUE 1
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_UNSIGNED_INT 0x1405
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_VENDOR 0x1F00
-#define GL_VERSION 0x1F02
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_VIEWPORT 0x0BA2
-#define GL_ZERO 0
diff --git a/src/threed/api/gl-gen-funcs.pl b/src/threed/api/gl-gen-funcs.pl
deleted file mode 100755
index 8f495649..00000000
--- a/src/threed/api/gl-gen-funcs.pl
+++ /dev/null
@@ -1,484 +0,0 @@
-#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
-## Contact: Nokia Corporation (qt-info@nokia.com)
-##
-## This file is part of the QtQuick3D 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$
-##
-#############################################################################
-
-
-#
-# USAGE:
-#
-# perl gl-gen-funcs.pl < gl-functs.txt > output.txt
-#
-# This will automatically generate the qopenglfunctions.h/.cpp files for Qt3D
-# based on the platform and available functions/capabilities.
-#
-# The file output.txt will contain the text for the header and implementation
-# files - it is left to the user to manually cut and paste this content into
-# their own qopenglfunctions.h and qopenglfunctions.cpp files.
-#
-# Note: this script is intended for perl version 5.10.1 or better, and has not
-# been tested on previous versions of perl.
-#
-
-use strict;
-use warnings;
-
-use Data::Dumper;
-
-# Read the function definitions from the input.
-my @functions = ();
-my @macros = ();
-my %func_info = ();
-while (<>)
-{
- my ($returnType, $name, $argstr) =
- m/^(\w+|const GLubyte\*)\s+(\w+)\s*\(([^)]*)\)/;
-
- if (!$returnType) {
- my ($macroname, $macrovalue) = m/^#define\s+(\w+)\s+(.*)$/;
- if ($macroname) {
- my %macro_info = ();
- $macro_info{'name'} = $macroname;
- $macro_info{'value'} = $macrovalue;
- push @macros, { %macro_info };
- next;
- }
- my ($tag, $value) = m/^\s+(\w+)\s+(.*)$/;
- next unless $tag;
- $func_info{$tag} = $value;
- $func_info{'funcname'} = $value if ($tag eq "es_name");
- next;
- }
-
- if ($func_info{'name'}) {
- push @functions, { %func_info };
- %func_info = ();
- }
-
- $argstr =~ s/^\s+//;
- $argstr =~ s/\s+$//;
- my @args = split /,\s*/,$argstr;
-
- my @argNames = ();
- if ($argstr ne 'void') {
- foreach (@args) {
- my ($argType, $argName) = m/^(\w+|\w+.*\*)\s+(\w+)$/;
- push @argNames, $argName;
- }
- } else {
- $argstr = "";
- }
- my $argnamestr = join(', ', @argNames);
-
- $func_info{'name'} = $name;
- $func_info{'funcname'} = $name;
- $name =~ s/^gl//;
- $func_info{'varname'} = lcfirst($name);
- $func_info{'returnType'} = $returnType;
- $func_info{'argstr'} = $argstr;
- $func_info{'argnamestr'} = $argnamestr;
-}
-if ($func_info{'name'}) {
- push @functions, { %func_info };
-}
-
-# Generate the declarations for qopenglfunctions.h.
-print "// qopenglfunctions.h\n\n";
-print "#ifdef Q_WS_WIN\n";
-print "# define QT3D_GLF_APIENTRY APIENTRY\n";
-print "#endif\n";
-print "\n";
-print "#ifndef Q_WS_MAC\n";
-print "# ifndef QT3D_GLF_APIENTRYP\n";
-print "# ifdef QT3D_GLF_APIENTRY\n";
-print "# define QT3D_GLF_APIENTRYP QT3D_GLF_APIENTRY *\n";
-print "# else\n";
-print "# define QT3D_GLF_APIENTRY\n";
-print "# define QT3D_GLF_APIENTRYP *\n";
-print "# endif\n";
-print "# endif\n";
-print "#else\n";
-print "# define QT3D_GLF_APIENTRY\n";
-print "# define QT3D_GLF_APIENTRYP *\n";
-print "#endif\n";
-print "\n";
-print "struct QOpenGLFunctionsPrivate;\n";
-print "\n";
-
-print "// Undefine any macros from GLEW, qglextensions_p.h, etc that\n";
-print "// may interfere with the definition of QOpenGLFunctions.\n";
-foreach ( @functions ) {
- my $inline = $_->{'inline'};
- next if ($inline && $inline eq 'all');
- my $name = $_->{'funcname'};
- print "#undef $name\n";
-}
-print "\n";
-
-# Output the prototypes into the QOpenGLFunctions class.
-print "class Q_QT3D_EXPORT QOpenGLFunctions\n";
-print "{\n";
-print "public:\n";
-print " QOpenGLFunctions();\n";
-print " explicit QOpenGLFunctions(const QGLContext *context);\n";
-print " ~QOpenGLFunctions() {}\n";
-print "\n";
-print " enum OpenGLFeature\n";
-print " {\n";
-print " Multitexture = 0x0001,\n";
-print " Shaders = 0x0002,\n";
-print " Buffers = 0x0004,\n";
-print " Framebuffers = 0x0008,\n";
-print " BlendColor = 0x0010,\n";
-print " BlendEquation = 0x0020,\n";
-print " BlendEquationSeparate = 0x0040,\n";
-print " BlendFuncSeparate = 0x0080,\n";
-print " BlendSubtract = 0x0100,\n";
-print " CompressedTextures = 0x0200,\n";
-print " Multisample = 0x0400,\n";
-print " StencilSeparate = 0x0800,\n";
-print " NPOTTextures = 0x1000\n";
-print " };\n";
-print " Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)\n";
-print "\n";
-print " QOpenGLFunctions::OpenGLFeatures openGLFeatures() const;\n";
-print " bool hasOpenGLFeature(QOpenGLFunctions::OpenGLFeature feature) const;\n";
-print "\n";
-print " void initializeGLFunctions(const QGLContext *context = 0);\n";
-print "\n";
-my $last_shader_only = 0;
-foreach ( @functions ) {
- my $inline = $_->{'inline'};
- next if ($inline && $inline eq 'all');
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
- my $name = $_->{'funcname'};
- #print "#ifndef QT_OPENGL_ES_1\n" if ($shader_only && !$last_shader_only);
- #print "#endif\n" if (!$shader_only && $last_shader_only);
- print " $_->{'returnType'} $name($_->{'argstr'});\n";
- $last_shader_only = $shader_only;
-}
-#print "#endif\n" if $last_shader_only;
-
-print "\n";
-print "private:\n";
-print " QOpenGLFunctionsPrivate *d_ptr;\n";
-print " static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; }\n";
-print "};\n";
-print "\n";
-print "Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLFunctions::OpenGLFeatures)\n";
-print "\n";
-print "struct QOpenGLFunctionsPrivate\n";
-print "{\n";
-print " QOpenGLFunctionsPrivate(const QGLContext *context = 0);\n";
-print "\n";
-print "#ifndef QT_OPENGL_ES_2";
-print "\n";
-
-# Output the function pointers into the QOpenGLFunctionsPrivate class.
-$last_shader_only = 0;
-foreach ( @functions ) {
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
- my $inline = $_->{'inline'};
- next if ($inline && $inline eq 'all');
- next if $inline && $inline eq 'all_diff';
- my $name = $_->{'varname'};
- #print "#ifndef QT_OPENGL_ES_1\n" if ($shader_only && !$last_shader_only);
- #print "#endif\n" if (!$shader_only && $last_shader_only);
- print " $_->{'returnType'} (QT3D_GLF_APIENTRYP $name)($_->{'argstr'});\n";
- $last_shader_only = $shader_only;
-}
-#print "#endif\n" if $last_shader_only;
-
-print "#endif\n";
-print "};\n";
-print "\n";
-
-my %platform_defines = ();
-$platform_defines{'es1'} = "defined(QT_OPENGL_ES_1)";
-$platform_defines{'es2'} = "defined(QT_OPENGL_ES_2)";
-$platform_defines{'es'} = "defined(QT_OPENGL_ES)";
-$platform_defines{'desktop'} = "!defined(QT_OPENGL_ES)";
-
-# Output the inline functions that call either the raw GL function
-# or resolve via the function pointer.
-$last_shader_only = 0;
-foreach ( @functions ) {
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
- my $funcname = $_->{'funcname'};
- my $varname = $_->{'varname'};
- my $is_void = ($_->{'returnType'} eq 'void');
- my $inline = $_->{'inline'};
- next if ($inline && $inline eq 'all');
- #print "#ifndef QT_OPENGL_ES_1\n\n" if ($shader_only && !$last_shader_only);
- #print "#endif\n\n" if (!$shader_only && $last_shader_only);
- print "inline $_->{'returnType'} QOpenGLFunctions::$funcname($_->{'argstr'})\n";
- print "{\n";
- if ($_->{'es_name'}) {
- # Functions like glClearDepth() that are inline, but named differently.
- print "#ifndef QT_OPENGL_ES\n";
- print " ::$_->{'name'}($_->{'argnamestr'});\n";
- print "#else\n";
- print " ::$_->{'es_name'}($_->{'argnamestr'});\n";
- print "#endif\n";
- } elsif ($inline && $inline eq 'all') {
- # Inlined on all platforms.
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "::$_->{'name'}($_->{'argnamestr'});\n";
- } elsif ($inline) {
- # Inlined only on certain platforms.
- my @platforms = split /,\s*/,$inline;
- my @defines = ();
- foreach (@platforms) {
- push @defines, $platform_defines{$_};
- }
- print "#if ";
- print join(' || ', @defines);
- print "\n";
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "::$_->{'name'}($_->{'argnamestr'});\n";
- print "#else\n";
- print " Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));\n";
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "d_ptr->$varname($_->{'argnamestr'});\n";
- print "#endif\n";
- } else {
- # Resolve on all platforms.
- print " Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));\n";
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "d_ptr->$varname($_->{'argnamestr'});\n";
- }
- print "}\n\n";
- $last_shader_only = $shader_only;
-}
-#print "#endif\n" if $last_shader_only;
-
-# Output the macro definitions.
-foreach ( @macros ) {
- my $name = $_->{'name'};
- my $value = $_->{'value'};
- print "#ifndef $name\n";
- print "#define $name $value\n";
- print "#endif\n";
-}
-print "\n";
-
-print "// qopenglfunctions.cpp\n\n";
-
-# Generate qdoc documentation for all of the functions.
-foreach ( @functions ) {
- my $inline = $_->{'inline'};
- next if $inline && $inline eq 'all';
-
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
-
- my $name = $_->{'funcname'};
-
- my $docargs = $_->{'argnamestr'};
- if (length($docargs) > 0) {
- $docargs =~ s/,/, \\a/g;
- $docargs =~ s/^/\\a /;
- }
-
- my $khronos_name = $_->{'es_name'};
- if (!$khronos_name) {
- $khronos_name = $_->{'name'};
- }
-
- print "/*!\n";
- print " \\fn $_->{'returnType'} QOpenGLFunctions::$name($_->{'argstr'})\n";
- print "\n";
- if ($khronos_name eq $_->{'name'}) {
- print " Convenience function that calls $khronos_name($docargs).\n";
- } else {
- print " Convenience function that calls $_->{'name'}($docargs) on\n";
- print " desktop OpenGL systems and $khronos_name($docargs) on\n";
- print " embedded OpenGL/ES systems.\n";
- }
- print "\n";
- print " For more information, see the OpenGL/ES 2.0 documentation for\n";
- print " \\l{http://www.khronos.org/opengles/sdk/docs/man/$khronos_name.xml}{$khronos_name()}.\n";
- if ($shader_only) {
- print "\n";
- print " This convenience function will do nothing on OpenGL/ES 1.x systems.\n";
- }
- print "*/\n\n";
-}
-
-# Generate the resolver functions.
-print "#ifndef QT_OPENGL_ES_2\n\n";
-$last_shader_only = 0;
-foreach ( @functions ) {
- my $inline = $_->{'inline'};
- next if $inline && $inline eq 'all';
- next if $inline && $inline eq 'all_diff';
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
- my $name = $_->{'varname'};
- my $resolver_name = $_->{'name'};
- $resolver_name =~ s/^gl/qglfResolve/;
- my $special_name = $_->{'name'};
- $special_name =~ s/^gl/qglfSpecial/;
- my @platforms = split /,\s*/,$inline;
- $shader_only = 1 if @platforms ~~ 'es1';
- my $is_void = ($_->{'returnType'} eq 'void');
- my $special_handling = ($_->{'special_handling'} && $_->{'special_handling'} eq 'yes');
- #print "#ifndef QT_OPENGL_ES_1\n\n" if ($shader_only && !$last_shader_only);
- #print "#endif\n\n" if (!$shader_only && $last_shader_only);
-
- if ($special_handling) {
- # Output special fallback implementations for certain functions.
- if ($name eq "getShaderPrecisionFormat") {
- print "static $_->{'returnType'} QT3D_GLF_APIENTRY $special_name($_->{'argstr'})\n";
- print "{\n";
- print " Q_UNUSED(shadertype);\n";
- print " Q_UNUSED(precisiontype);\n";
- print " range[0] = range[1] = precision[0] = 0;\n";
- print "}\n\n";
- } elsif ($name eq "isProgram" || $name eq "isShader") {
- print "static $_->{'returnType'} QT3D_GLF_APIENTRY $special_name($_->{'argstr'})\n";
- print "{\n";
- print " return $_->{'argnamestr'} != 0;\n";
- print "}\n\n";
- } elsif ($name eq "releaseShaderCompiler") {
- print "static $_->{'returnType'} QT3D_GLF_APIENTRY $special_name($_->{'argstr'})\n";
- print "{\n";
- print "}\n\n";
- }
- }
-
- print "static $_->{'returnType'} QT3D_GLF_APIENTRY $resolver_name($_->{'argstr'})\n";
- print "{\n";
- my $type_name = "type_$_->{'name'}";
- print " typedef $_->{'returnType'} (QT3D_GLF_APIENTRYP $type_name)($_->{'argstr'});\n\n";
- print " const QGLContext *context = QGLContext::currentContext();\n";
- print " QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);\n";
- print "\n";
- print " funcs->$name = ($type_name)\n";
- print " context->getProcAddress(QLatin1String(\"$_->{'name'}\"));\n";
- my @alt_names = ();
- if ($_->{'alt_name'}) {
- push @alt_names, $_->{'alt_name'};
- } else {
- push @alt_names, "$_->{'name'}OES";
- push @alt_names, "$_->{'name'}EXT";
- push @alt_names, "$_->{'name'}ARB";
- }
- foreach (@alt_names) {
- print "#ifdef QT_OPENGL_ES\n" if /OES/;
- print " if (!funcs->$name) {\n";
- print " funcs->$name = ($type_name)\n";
- print " context->getProcAddress(QLatin1String(\"$_\"));\n";
- print " }\n";
- print "#endif\n" if /OES/;
- }
- if ($special_handling) {
- print "\n";
- print " if (!funcs->$name)\n";
- print " funcs->$name = $special_name;\n\n";
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "funcs->$name($_->{'argnamestr'});\n";
- } else {
- print "\n";
- print " if (funcs->$name)\n";
- if ($is_void) {
- print (" ");
- } else {
- print (" return ");
- }
- print "funcs->$name($_->{'argnamestr'});\n";
- if ($is_void) {
- print " else\n";
- print " funcs->$name = $resolver_name;\n";
- } else {
- print " funcs->$name = $resolver_name;\n";
- print " return $_->{'returnType'}(0);\n";
- }
- }
- print "}\n\n";
-
- $last_shader_only = $shader_only;
-}
-#print "#endif\n" if $last_shader_only;
-print "#endif // !QT_OPENGL_ES_2\n\n";
-
-# Generate the initialization code for QOpenGLFunctionsPrivate.
-print "QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(const QGLContext *)\n";
-print "{\n";
-print "#ifndef QT_OPENGL_ES_2\n";
-$last_shader_only = 0;
-foreach ( @functions ) {
- my $inline = $_->{'inline'};
- next if $inline && $inline eq 'all';
- next if $inline && $inline eq 'all_diff';
- my $shader_only = ($_->{'shader_only'} && $_->{'shader_only'} eq 'yes');
- my $name = $_->{'varname'};
- my $resolver_name = $_->{'name'};
- $resolver_name =~ s/^gl/qglfResolve/;
- my @platforms = split /,\s*/,$inline;
- $shader_only = 1 if @platforms ~~ 'es1';
- #print "#ifndef QT_OPENGL_ES_1\n" if ($shader_only && !$last_shader_only);
- #print "#endif\n" if (!$shader_only && $last_shader_only);
- print " $name = $resolver_name;\n";
- $last_shader_only = $shader_only;
-}
-#print "#endif\n" if $last_shader_only;
-print "#endif // !QT_OPENGL_ES_2\n";
-print "}\n\n";
-
-#print Dumper(\@functions);
diff --git a/src/threed/api/qopenglfunctions.cpp b/src/threed/api/qopenglfunctions.cpp
deleted file mode 100644
index fabf3e04..00000000
--- a/src/threed/api/qopenglfunctions.cpp
+++ /dev/null
@@ -1,3690 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qopenglfunctions.h"
-#include "qglext_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QOpenGLFunctions
- \brief The QOpenGLFunctions class provides cross-platform access to the OpenGL/ES 2.0 API.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::enablers
-
- OpenGL/ES 2.0 defines a subset of the OpenGL specification that is
- common across many desktop and embedded OpenGL implementations.
- However, it can be difficult to use the functions from that subset
- because they need to be resolved manually on desktop systems.
-
- QOpenGLFunctions provides a guaranteed API that is available on all
- OpenGL systems and takes care of function resolution on systems
- that need it. The recommended way to use QOpenGLFunctions is by
- direct inheritance:
-
- \code
- class MyGLWidget : public QGLWidget, protected QOpenGLFunctions
- {
- Q_OBJECT
- public:
- MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {}
-
- protected:
- void initializeGL();
- void paintGL();
- };
-
- void MyGLWidget::initializeGL()
- {
- initializeGLFunctions();
- }
- \endcode
-
- The \c{paintGL()} function can then use any of the OpenGL/ES 2.0
- functions without explicit resolution, such as glActiveTexture()
- in the following example:
-
- \code
- void MyGLWidget::paintGL()
- {
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, textureId);
- ...
- }
- \endcode
-
- QOpenGLFunctions can also be used directly for ad-hoc invocation
- of OpenGL/ES 2.0 functions on all platforms:
-
- \code
- QOpenGLFunctions glFuncs(QGLContext::currentContext());
- glFuncs.glActiveTexture(GL_TEXTURE1);
- \endcode
-
- QOpenGLFunctions provides wrappers for all OpenGL/ES 2.0 functions,
- except those like \c{glDrawArrays()}, \c{glViewport()}, and
- \c{glBindTexture()} that don't have portability issues.
-
- Including the header for QOpenGLFunctions will also define all of
- the OpenGL/ES 2.0 macro constants that are not already defined by
- the system's OpenGL headers, such as \c{GL_TEXTURE1} above.
-
- The hasOpenGLFeature() and openGLFeatures() functions can be used
- to determine if the OpenGL implementation has a major OpenGL/ES 2.0
- feature. For example, the following checks if non power of two
- textures are available:
-
- \code
- QOpenGLFunctions funcs(QGLContext::currentContext());
- bool npot = funcs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
- \endcode
-*/
-
-/*!
- \enum QOpenGLFunctions::OpenGLFeature
- This enum defines OpenGL/ES 2.0 features that may be optional
- on other platforms.
-
- \value Multitexture glActiveTexture() function is available.
- \value Shaders Shader functions are available.
- \value Buffers Vertex and index buffer functions are available.
- \value Framebuffers Framebuffer object functions are available.
- \value BlendColor glBlendColor() is available.
- \value BlendEquation glBlendEquation() is available.
- \value BlendEquationSeparate glBlendEquationSeparate() is available.
- \value BlendFuncSeparate glBlendFuncSeparate() is available.
- \value BlendSubtract Blend subtract mode is available.
- \value CompressedTextures Compressed texture functions are available.
- \value Multisample glSampleCoverage() function is available.
- \value StencilSeparate Separate stencil functions are available.
- \value NPOTTextures Non power of two textures are available.
-*/
-
-// Hidden private fields for additional extension data.
-// Hidden private fields for additional extension data.
-struct QOpenGLFunctionsPrivateEx : public QOpenGLFunctionsPrivate
-{
- QOpenGLFunctionsPrivateEx(const QGLContext *context = 0)
- : QOpenGLFunctionsPrivate(context)
- , m_features(-1) {}
-
- int m_features;
-};
-
-Q_GLOBAL_STATIC(QGLResource<QOpenGLFunctionsPrivateEx>, qt_gl_functions_resource)
-
-static QOpenGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0)
-{
- if (!context)
- context = QGLContext::currentContext();
- Q_ASSERT(context);
- return qt_gl_functions_resource()->value(context);
-}
-
-/*!
- Constructs a default function resolver. The resolver cannot
- be used until initializeGLFunctions() is called to specify
- the context.
-
- \sa initializeGLFunctions()
-*/
-QOpenGLFunctions::QOpenGLFunctions()
- : d_ptr(0)
-{
-}
-
-/*!
- Constructs a function resolver for \a context. If \a context
- is null, then the resolver will be created for the current QGLContext.
-
- An object constructed in this way can only be used with \a context
- and other contexts that share with it. Use initializeGLFunctions()
- to change the object's context association.
-
- \sa initializeGLFunctions()
-*/
-QOpenGLFunctions::QOpenGLFunctions(const QGLContext *context)
- : d_ptr(qt_gl_functions(context))
-{
-}
-
-/*!
- \fn QOpenGLFunctions::~QOpenGLFunctions()
-
- Destroys this function resolver.
-*/
-
-static int qt_gl_resolve_features()
-{
-#if defined(QT_OPENGL_ES_2)
- return QOpenGLFunctions::Multitexture |
- QOpenGLFunctions::Shaders |
- QOpenGLFunctions::Buffers |
- QOpenGLFunctions::Framebuffers |
- QOpenGLFunctions::BlendColor |
- QOpenGLFunctions::BlendEquation |
- QOpenGLFunctions::BlendEquationSeparate |
- QOpenGLFunctions::BlendFuncSeparate |
- QOpenGLFunctions::BlendSubtract |
- QOpenGLFunctions::CompressedTextures |
- QOpenGLFunctions::Multisample |
- QOpenGLFunctions::StencilSeparate |
- QOpenGLFunctions::NPOTTextures;
-#elif defined(QT_OPENGL_ES)
- int features = QOpenGLFunctions::Multitexture |
- QOpenGLFunctions::Buffers |
- QOpenGLFunctions::CompressedTextures |
- QOpenGLFunctions::Multisample;
- QGLExtensionChecker extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
- if (extensions.match("GL_OES_framebuffer_object"))
- features |= QOpenGLFunctions::Framebuffers;
- if (extensions.match("GL_OES_blend_equation_separate"))
- features |= QOpenGLFunctions::BlendEquationSeparate;
- if (extensions.match("GL_OES_blend_func_separate"))
- features |= QOpenGLFunctions::BlendFuncSeparate;
- if (extensions.match("GL_OES_blend_subtract"))
- features |= QOpenGLFunctions::BlendSubtract;
- if (extensions.match("GL_OES_texture_npot"))
- features |= QOpenGLFunctions::NPOTTextures;
- return features;
-#else
- int features = 0;
- QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags();
- QGLExtensionChecker extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
-
- // Recognize features by extension name.
- if (extensions.match("GL_ARB_multitexture"))
- features |= QOpenGLFunctions::Multitexture;
- if (extensions.match("GL_ARB_shader_objects"))
- features |= QOpenGLFunctions::Shaders;
- if (extensions.match("GL_EXT_framebuffer_object") ||
- extensions.match("GL_ARB_framebuffer_object"))
- features |= QOpenGLFunctions::Framebuffers;
- if (extensions.match("GL_EXT_blend_color"))
- features |= QOpenGLFunctions::BlendColor;
- if (extensions.match("GL_EXT_blend_equation_separate"))
- features |= QOpenGLFunctions::BlendEquationSeparate;
- if (extensions.match("GL_EXT_blend_func_separate"))
- features |= QOpenGLFunctions::BlendFuncSeparate;
- if (extensions.match("GL_EXT_blend_subtract"))
- features |= QOpenGLFunctions::BlendSubtract;
- if (extensions.match("GL_ARB_texture_compression"))
- features |= QOpenGLFunctions::CompressedTextures;
- if (extensions.match("GL_ARB_multisample"))
- features |= QOpenGLFunctions::Multisample;
- if (extensions.match("GL_ARB_texture_non_power_of_two"))
- features |= QOpenGLFunctions::NPOTTextures;
-
- // Recognize features by minimum OpenGL version.
- if (versions & QGLFormat::OpenGL_Version_1_2) {
- features |= QOpenGLFunctions::BlendColor |
- QOpenGLFunctions::BlendEquation;
- }
- if (versions & QGLFormat::OpenGL_Version_1_3) {
- features |= QOpenGLFunctions::Multitexture |
- QOpenGLFunctions::CompressedTextures |
- QOpenGLFunctions::Multisample;
- }
- if (versions & QGLFormat::OpenGL_Version_1_4)
- features |= QOpenGLFunctions::BlendFuncSeparate;
- if (versions & QGLFormat::OpenGL_Version_1_5)
- features |= QOpenGLFunctions::Buffers;
- if (versions & QGLFormat::OpenGL_Version_2_0) {
- features |= QOpenGLFunctions::Shaders |
- QOpenGLFunctions::StencilSeparate |
- QOpenGLFunctions::BlendEquationSeparate |
- QOpenGLFunctions::NPOTTextures;
- }
- return features;
-#endif
-}
-
-/*!
- Returns the set of features that are present on this system's
- OpenGL implementation.
-
- It is assumed that the QGLContext associated with this function
- resolver is current.
-
- \sa hasOpenGLFeature()
-*/
-QOpenGLFunctions::OpenGLFeatures QOpenGLFunctions::openGLFeatures() const
-{
- QOpenGLFunctionsPrivateEx *d = static_cast<QOpenGLFunctionsPrivateEx *>(d_ptr);
- if (!d)
- return 0;
- if (d->m_features == -1)
- d->m_features = qt_gl_resolve_features();
- return QOpenGLFunctions::OpenGLFeatures(d->m_features);
-}
-
-/*!
- Returns true if \a feature is present on this system's OpenGL
- implementation; false otherwise.
-
- It is assumed that the QGLContext associated with this function
- resolver is current.
-
- \sa openGLFeatures()
-*/
-bool QOpenGLFunctions::hasOpenGLFeature(QOpenGLFunctions::OpenGLFeature feature) const
-{
- QOpenGLFunctionsPrivateEx *d = static_cast<QOpenGLFunctionsPrivateEx *>(d_ptr);
- if (!d)
- return false;
- if (d->m_features == -1)
- d->m_features = qt_gl_resolve_features();
- return (d->m_features & int(feature)) != 0;
-}
-
-/*!
- Initializes GL function resolution for \a context. If \a context
- is null, then the current QGLContext will be used.
-
- After calling this function, the QOpenGLFunctions object can only be
- used with \a context and other contexts that share with it.
- Call initializeGLFunctions() again to change the object's context
- association.
-*/
-void QOpenGLFunctions::initializeGLFunctions(const QGLContext *context)
-{
- d_ptr = qt_gl_functions(context);
-}
-
-
-/*!
- \fn void QOpenGLFunctions::glActiveTexture(GLenum texture)
-
- Convenience function that calls glActiveTexture(\a texture).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glActiveTexture.xml}{glActiveTexture()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glAttachShader(GLuint program, GLuint shader)
-
- Convenience function that calls glAttachShader(\a program, \a shader).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glAttachShader.xml}{glAttachShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
-
- Convenience function that calls glBindAttribLocation(\a program, \a index, \a name).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBindAttribLocation.xml}{glBindAttribLocation()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
-
- Convenience function that calls glBindBuffer(\a target, \a buffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBindBuffer.xml}{glBindBuffer()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
-
- Convenience function that calls glBindFramebuffer(\a target, \a framebuffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBindFramebuffer.xml}{glBindFramebuffer()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
-
- Convenience function that calls glBindRenderbuffer(\a target, \a renderbuffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBindRenderbuffer.xml}{glBindRenderbuffer()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-
- Convenience function that calls glBlendColor(\a red, \a green, \a blue, \a alpha).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendColor.xml}{glBlendColor()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBlendEquation(GLenum mode)
-
- Convenience function that calls glBlendEquation(\a mode).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquation.xml}{glBlendEquation()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
-
- Convenience function that calls glBlendEquationSeparate(\a modeRGB, \a modeAlpha).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquationSeparate.xml}{glBlendEquationSeparate()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
-
- Convenience function that calls glBlendFuncSeparate(\a srcRGB, \a dstRGB, \a srcAlpha, \a dstAlpha).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendFuncSeparate.xml}{glBlendFuncSeparate()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
-
- Convenience function that calls glBufferData(\a target, \a size, \a data, \a usage).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferData.xml}{glBufferData()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
-
- Convenience function that calls glBufferSubData(\a target, \a offset, \a size, \a data).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferSubData.xml}{glBufferSubData()}.
-*/
-
-/*!
- \fn GLenum QOpenGLFunctions::glCheckFramebufferStatus(GLenum target)
-
- Convenience function that calls glCheckFramebufferStatus(\a target).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCheckFramebufferStatus.xml}{glCheckFramebufferStatus()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glClearDepthf(GLclampf depth)
-
- Convenience function that calls glClearDepth(\a depth) on
- desktop OpenGL systems and glClearDepthf(\a depth) on
- embedded OpenGL/ES systems.
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glClearDepthf.xml}{glClearDepthf()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glCompileShader(GLuint shader)
-
- Convenience function that calls glCompileShader(\a shader).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCompileShader.xml}{glCompileShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
-
- Convenience function that calls glCompressedTexImage2D(\a target, \a level, \a internalformat, \a width, \a height, \a border, \a imageSize, \a data).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexImage2D.xml}{glCompressedTexImage2D()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
-
- Convenience function that calls glCompressedTexSubImage2D(\a target, \a level, \a xoffset, \a yoffset, \a width, \a height, \a format, \a imageSize, \a data).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexSubImage2D.xml}{glCompressedTexSubImage2D()}.
-*/
-
-/*!
- \fn GLuint QOpenGLFunctions::glCreateProgram()
-
- Convenience function that calls glCreateProgram().
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateProgram.xml}{glCreateProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn GLuint QOpenGLFunctions::glCreateShader(GLenum type)
-
- Convenience function that calls glCreateShader(\a type).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateShader.xml}{glCreateShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
-
- Convenience function that calls glDeleteBuffers(\a n, \a buffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteBuffers.xml}{glDeleteBuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
-
- Convenience function that calls glDeleteFramebuffers(\a n, \a framebuffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteFramebuffers.xml}{glDeleteFramebuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDeleteProgram(GLuint program)
-
- Convenience function that calls glDeleteProgram(\a program).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteProgram.xml}{glDeleteProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
-
- Convenience function that calls glDeleteRenderbuffers(\a n, \a renderbuffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteRenderbuffers.xml}{glDeleteRenderbuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDeleteShader(GLuint shader)
-
- Convenience function that calls glDeleteShader(\a shader).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteShader.xml}{glDeleteShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
-
- Convenience function that calls glDepthRange(\a zNear, \a zFar) on
- desktop OpenGL systems and glDepthRangef(\a zNear, \a zFar) on
- embedded OpenGL/ES systems.
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDepthRangef.xml}{glDepthRangef()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDetachShader(GLuint program, GLuint shader)
-
- Convenience function that calls glDetachShader(\a program, \a shader).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDetachShader.xml}{glDetachShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glDisableVertexAttribArray(GLuint index)
-
- Convenience function that calls glDisableVertexAttribArray(\a index).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glDisableVertexAttribArray.xml}{glDisableVertexAttribArray()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glEnableVertexAttribArray(GLuint index)
-
- Convenience function that calls glEnableVertexAttribArray(\a index).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glEnableVertexAttribArray.xml}{glEnableVertexAttribArray()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
-
- Convenience function that calls glFramebufferRenderbuffer(\a target, \a attachment, \a renderbuffertarget, \a renderbuffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferRenderbuffer.xml}{glFramebufferRenderbuffer()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-
- Convenience function that calls glFramebufferTexture2D(\a target, \a attachment, \a textarget, \a texture, \a level).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferTexture2D.xml}{glFramebufferTexture2D()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
-
- Convenience function that calls glGenBuffers(\a n, \a buffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGenBuffers.xml}{glGenBuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGenerateMipmap(GLenum target)
-
- Convenience function that calls glGenerateMipmap(\a target).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGenerateMipmap.xml}{glGenerateMipmap()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
-
- Convenience function that calls glGenFramebuffers(\a n, \a framebuffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGenFramebuffers.xml}{glGenFramebuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
-
- Convenience function that calls glGenRenderbuffers(\a n, \a renderbuffers).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGenRenderbuffers.xml}{glGenRenderbuffers()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-
- Convenience function that calls glGetActiveAttrib(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveAttrib.xml}{glGetActiveAttrib()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-
- Convenience function that calls glGetActiveUniform(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveUniform.xml}{glGetActiveUniform()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
-
- Convenience function that calls glGetAttachedShaders(\a program, \a maxcount, \a count, \a shaders).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttachedShaders.xml}{glGetAttachedShaders()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn int QOpenGLFunctions::glGetAttribLocation(GLuint program, const char* name)
-
- Convenience function that calls glGetAttribLocation(\a program, \a name).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttribLocation.xml}{glGetAttribLocation()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
-
- Convenience function that calls glGetBufferParameteriv(\a target, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetBufferParameteriv.xml}{glGetBufferParameteriv()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
-
- Convenience function that calls glGetFramebufferAttachmentParameteriv(\a target, \a attachment, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetFramebufferAttachmentParameteriv.xml}{glGetFramebufferAttachmentParameteriv()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
-
- Convenience function that calls glGetProgramiv(\a program, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramiv.xml}{glGetProgramiv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
-
- Convenience function that calls glGetProgramInfoLog(\a program, \a bufsize, \a length, \a infolog).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramInfoLog.xml}{glGetProgramInfoLog()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
-
- Convenience function that calls glGetRenderbufferParameteriv(\a target, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetRenderbufferParameteriv.xml}{glGetRenderbufferParameteriv()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
-
- Convenience function that calls glGetShaderiv(\a shader, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderiv.xml}{glGetShaderiv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
-
- Convenience function that calls glGetShaderInfoLog(\a shader, \a bufsize, \a length, \a infolog).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderInfoLog.xml}{glGetShaderInfoLog()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-
- Convenience function that calls glGetShaderPrecisionFormat(\a shadertype, \a precisiontype, \a range, \a precision).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderPrecisionFormat.xml}{glGetShaderPrecisionFormat()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
-
- Convenience function that calls glGetShaderSource(\a shader, \a bufsize, \a length, \a source).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderSource.xml}{glGetShaderSource()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
-
- Convenience function that calls glGetUniformfv(\a program, \a location, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformfv.xml}{glGetUniformfv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
-
- Convenience function that calls glGetUniformiv(\a program, \a location, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformiv.xml}{glGetUniformiv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn int QOpenGLFunctions::glGetUniformLocation(GLuint program, const char* name)
-
- Convenience function that calls glGetUniformLocation(\a program, \a name).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformLocation.xml}{glGetUniformLocation()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
-
- Convenience function that calls glGetVertexAttribfv(\a index, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribfv.xml}{glGetVertexAttribfv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
-
- Convenience function that calls glGetVertexAttribiv(\a index, \a pname, \a params).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribiv.xml}{glGetVertexAttribiv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
-
- Convenience function that calls glGetVertexAttribPointerv(\a index, \a pname, \a pointer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribPointerv.xml}{glGetVertexAttribPointerv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn GLboolean QOpenGLFunctions::glIsBuffer(GLuint buffer)
-
- Convenience function that calls glIsBuffer(\a buffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glIsBuffer.xml}{glIsBuffer()}.
-*/
-
-/*!
- \fn GLboolean QOpenGLFunctions::glIsFramebuffer(GLuint framebuffer)
-
- Convenience function that calls glIsFramebuffer(\a framebuffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glIsFramebuffer.xml}{glIsFramebuffer()}.
-*/
-
-/*!
- \fn GLboolean QOpenGLFunctions::glIsProgram(GLuint program)
-
- Convenience function that calls glIsProgram(\a program).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glIsProgram.xml}{glIsProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn GLboolean QOpenGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
-
- Convenience function that calls glIsRenderbuffer(\a renderbuffer).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glIsRenderbuffer.xml}{glIsRenderbuffer()}.
-*/
-
-/*!
- \fn GLboolean QOpenGLFunctions::glIsShader(GLuint shader)
-
- Convenience function that calls glIsShader(\a shader).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glIsShader.xml}{glIsShader()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glLinkProgram(GLuint program)
-
- Convenience function that calls glLinkProgram(\a program).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glLinkProgram.xml}{glLinkProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glReleaseShaderCompiler()
-
- Convenience function that calls glReleaseShaderCompiler().
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glReleaseShaderCompiler.xml}{glReleaseShaderCompiler()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
-
- Convenience function that calls glRenderbufferStorage(\a target, \a internalformat, \a width, \a height).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glRenderbufferStorage.xml}{glRenderbufferStorage()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
-
- Convenience function that calls glSampleCoverage(\a value, \a invert).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glSampleCoverage.xml}{glSampleCoverage()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
-
- Convenience function that calls glShaderBinary(\a n, \a shaders, \a binaryformat, \a binary, \a length).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderBinary.xml}{glShaderBinary()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
-
- Convenience function that calls glShaderSource(\a shader, \a count, \a string, \a length).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderSource.xml}{glShaderSource()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
-
- Convenience function that calls glStencilFuncSeparate(\a face, \a func, \a ref, \a mask).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilFuncSeparate.xml}{glStencilFuncSeparate()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
-
- Convenience function that calls glStencilMaskSeparate(\a face, \a mask).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilMaskSeparate.xml}{glStencilMaskSeparate()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
-
- Convenience function that calls glStencilOpSeparate(\a face, \a fail, \a zfail, \a zpass).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilOpSeparate.xml}{glStencilOpSeparate()}.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform1f(GLint location, GLfloat x)
-
- Convenience function that calls glUniform1f(\a location, \a x).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1f.xml}{glUniform1f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
-
- Convenience function that calls glUniform1fv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1fv.xml}{glUniform1fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform1i(GLint location, GLint x)
-
- Convenience function that calls glUniform1i(\a location, \a x).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1i.xml}{glUniform1i()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
-
- Convenience function that calls glUniform1iv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1iv.xml}{glUniform1iv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
-
- Convenience function that calls glUniform2f(\a location, \a x, \a y).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2f.xml}{glUniform2f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
-
- Convenience function that calls glUniform2fv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2fv.xml}{glUniform2fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
-
- Convenience function that calls glUniform2i(\a location, \a x, \a y).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2i.xml}{glUniform2i()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
-
- Convenience function that calls glUniform2iv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2iv.xml}{glUniform2iv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
-
- Convenience function that calls glUniform3f(\a location, \a x, \a y, \a z).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3f.xml}{glUniform3f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
-
- Convenience function that calls glUniform3fv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3fv.xml}{glUniform3fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
-
- Convenience function that calls glUniform3i(\a location, \a x, \a y, \a z).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3i.xml}{glUniform3i()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
-
- Convenience function that calls glUniform3iv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3iv.xml}{glUniform3iv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-
- Convenience function that calls glUniform4f(\a location, \a x, \a y, \a z, \a w).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4f.xml}{glUniform4f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
-
- Convenience function that calls glUniform4fv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4fv.xml}{glUniform4fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
-
- Convenience function that calls glUniform4i(\a location, \a x, \a y, \a z, \a w).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4i.xml}{glUniform4i()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
-
- Convenience function that calls glUniform4iv(\a location, \a count, \a v).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4iv.xml}{glUniform4iv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-
- Convenience function that calls glUniformMatrix2fv(\a location, \a count, \a transpose, \a value).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix2fv.xml}{glUniformMatrix2fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-
- Convenience function that calls glUniformMatrix3fv(\a location, \a count, \a transpose, \a value).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix3fv.xml}{glUniformMatrix3fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-
- Convenience function that calls glUniformMatrix4fv(\a location, \a count, \a transpose, \a value).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix4fv.xml}{glUniformMatrix4fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glUseProgram(GLuint program)
-
- Convenience function that calls glUseProgram(\a program).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glUseProgram.xml}{glUseProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glValidateProgram(GLuint program)
-
- Convenience function that calls glValidateProgram(\a program).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glValidateProgram.xml}{glValidateProgram()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
-
- Convenience function that calls glVertexAttrib1f(\a indx, \a x).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1f.xml}{glVertexAttrib1f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
-
- Convenience function that calls glVertexAttrib1fv(\a indx, \a values).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1fv.xml}{glVertexAttrib1fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
-
- Convenience function that calls glVertexAttrib2f(\a indx, \a x, \a y).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2f.xml}{glVertexAttrib2f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
-
- Convenience function that calls glVertexAttrib2fv(\a indx, \a values).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2fv.xml}{glVertexAttrib2fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
-
- Convenience function that calls glVertexAttrib3f(\a indx, \a x, \a y, \a z).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3f.xml}{glVertexAttrib3f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
-
- Convenience function that calls glVertexAttrib3fv(\a indx, \a values).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3fv.xml}{glVertexAttrib3fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-
- Convenience function that calls glVertexAttrib4f(\a indx, \a x, \a y, \a z, \a w).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4f.xml}{glVertexAttrib4f()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
-
- Convenience function that calls glVertexAttrib4fv(\a indx, \a values).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4fv.xml}{glVertexAttrib4fv()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-/*!
- \fn void QOpenGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
-
- Convenience function that calls glVertexAttribPointer(\a indx, \a size, \a type, \a normalized, \a stride, \a ptr).
-
- For more information, see the OpenGL/ES 2.0 documentation for
- \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttribPointer.xml}{glVertexAttribPointer()}.
-
- This convenience function will do nothing on OpenGL/ES 1.x systems.
-*/
-
-#ifndef QT_OPENGL_ES_2
-
-static void QT3D_GLF_APIENTRY qglfResolveActiveTexture(GLenum texture)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glActiveTexture)(GLenum texture);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->activeTexture = (type_glActiveTexture)
- context->getProcAddress(QLatin1String("glActiveTexture"));
- if (!funcs->activeTexture) {
- funcs->activeTexture = (type_glActiveTexture)
- context->getProcAddress(QLatin1String("glActiveTextureARB"));
- }
-
- if (funcs->activeTexture)
- funcs->activeTexture(texture);
- else
- funcs->activeTexture = qglfResolveActiveTexture;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveAttachShader(GLuint program, GLuint shader)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glAttachShader)(GLuint program, GLuint shader);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->attachShader = (type_glAttachShader)
- context->getProcAddress(QLatin1String("glAttachShader"));
- if (!funcs->attachShader) {
- funcs->attachShader = (type_glAttachShader)
- context->getProcAddress(QLatin1String("glAttachObjectARB"));
- }
-
- if (funcs->attachShader)
- funcs->attachShader(program, shader);
- else
- funcs->attachShader = qglfResolveAttachShader;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBindAttribLocation(GLuint program, GLuint index, const char* name)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBindAttribLocation)(GLuint program, GLuint index, const char* name);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bindAttribLocation = (type_glBindAttribLocation)
- context->getProcAddress(QLatin1String("glBindAttribLocation"));
- if (!funcs->bindAttribLocation) {
- funcs->bindAttribLocation = (type_glBindAttribLocation)
- context->getProcAddress(QLatin1String("glBindAttribLocationARB"));
- }
-
- if (funcs->bindAttribLocation)
- funcs->bindAttribLocation(program, index, name);
- else
- funcs->bindAttribLocation = qglfResolveBindAttribLocation;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBindBuffer(GLenum target, GLuint buffer)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBindBuffer)(GLenum target, GLuint buffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bindBuffer = (type_glBindBuffer)
- context->getProcAddress(QLatin1String("glBindBuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->bindBuffer) {
- funcs->bindBuffer = (type_glBindBuffer)
- context->getProcAddress(QLatin1String("glBindBufferOES"));
- }
-#endif
- if (!funcs->bindBuffer) {
- funcs->bindBuffer = (type_glBindBuffer)
- context->getProcAddress(QLatin1String("glBindBufferEXT"));
- }
- if (!funcs->bindBuffer) {
- funcs->bindBuffer = (type_glBindBuffer)
- context->getProcAddress(QLatin1String("glBindBufferARB"));
- }
-
- if (funcs->bindBuffer)
- funcs->bindBuffer(target, buffer);
- else
- funcs->bindBuffer = qglfResolveBindBuffer;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBindFramebuffer(GLenum target, GLuint framebuffer)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBindFramebuffer)(GLenum target, GLuint framebuffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bindFramebuffer = (type_glBindFramebuffer)
- context->getProcAddress(QLatin1String("glBindFramebuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->bindFramebuffer) {
- funcs->bindFramebuffer = (type_glBindFramebuffer)
- context->getProcAddress(QLatin1String("glBindFramebufferOES"));
- }
-#endif
- if (!funcs->bindFramebuffer) {
- funcs->bindFramebuffer = (type_glBindFramebuffer)
- context->getProcAddress(QLatin1String("glBindFramebufferEXT"));
- }
- if (!funcs->bindFramebuffer) {
- funcs->bindFramebuffer = (type_glBindFramebuffer)
- context->getProcAddress(QLatin1String("glBindFramebufferARB"));
- }
-
- if (funcs->bindFramebuffer)
- funcs->bindFramebuffer(target, framebuffer);
- else
- funcs->bindFramebuffer = qglfResolveBindFramebuffer;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBindRenderbuffer(GLenum target, GLuint renderbuffer)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bindRenderbuffer = (type_glBindRenderbuffer)
- context->getProcAddress(QLatin1String("glBindRenderbuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->bindRenderbuffer) {
- funcs->bindRenderbuffer = (type_glBindRenderbuffer)
- context->getProcAddress(QLatin1String("glBindRenderbufferOES"));
- }
-#endif
- if (!funcs->bindRenderbuffer) {
- funcs->bindRenderbuffer = (type_glBindRenderbuffer)
- context->getProcAddress(QLatin1String("glBindRenderbufferEXT"));
- }
- if (!funcs->bindRenderbuffer) {
- funcs->bindRenderbuffer = (type_glBindRenderbuffer)
- context->getProcAddress(QLatin1String("glBindRenderbufferARB"));
- }
-
- if (funcs->bindRenderbuffer)
- funcs->bindRenderbuffer(target, renderbuffer);
- else
- funcs->bindRenderbuffer = qglfResolveBindRenderbuffer;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->blendColor = (type_glBlendColor)
- context->getProcAddress(QLatin1String("glBlendColor"));
-#ifdef QT_OPENGL_ES
- if (!funcs->blendColor) {
- funcs->blendColor = (type_glBlendColor)
- context->getProcAddress(QLatin1String("glBlendColorOES"));
- }
-#endif
- if (!funcs->blendColor) {
- funcs->blendColor = (type_glBlendColor)
- context->getProcAddress(QLatin1String("glBlendColorEXT"));
- }
- if (!funcs->blendColor) {
- funcs->blendColor = (type_glBlendColor)
- context->getProcAddress(QLatin1String("glBlendColorARB"));
- }
-
- if (funcs->blendColor)
- funcs->blendColor(red, green, blue, alpha);
- else
- funcs->blendColor = qglfResolveBlendColor;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBlendEquation(GLenum mode)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBlendEquation)(GLenum mode);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->blendEquation = (type_glBlendEquation)
- context->getProcAddress(QLatin1String("glBlendEquation"));
-#ifdef QT_OPENGL_ES
- if (!funcs->blendEquation) {
- funcs->blendEquation = (type_glBlendEquation)
- context->getProcAddress(QLatin1String("glBlendEquationOES"));
- }
-#endif
- if (!funcs->blendEquation) {
- funcs->blendEquation = (type_glBlendEquation)
- context->getProcAddress(QLatin1String("glBlendEquationEXT"));
- }
- if (!funcs->blendEquation) {
- funcs->blendEquation = (type_glBlendEquation)
- context->getProcAddress(QLatin1String("glBlendEquationARB"));
- }
-
- if (funcs->blendEquation)
- funcs->blendEquation(mode);
- else
- funcs->blendEquation = qglfResolveBlendEquation;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
- context->getProcAddress(QLatin1String("glBlendEquationSeparate"));
-#ifdef QT_OPENGL_ES
- if (!funcs->blendEquationSeparate) {
- funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
- context->getProcAddress(QLatin1String("glBlendEquationSeparateOES"));
- }
-#endif
- if (!funcs->blendEquationSeparate) {
- funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
- context->getProcAddress(QLatin1String("glBlendEquationSeparateEXT"));
- }
- if (!funcs->blendEquationSeparate) {
- funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
- context->getProcAddress(QLatin1String("glBlendEquationSeparateARB"));
- }
-
- if (funcs->blendEquationSeparate)
- funcs->blendEquationSeparate(modeRGB, modeAlpha);
- else
- funcs->blendEquationSeparate = qglfResolveBlendEquationSeparate;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
- context->getProcAddress(QLatin1String("glBlendFuncSeparate"));
-#ifdef QT_OPENGL_ES
- if (!funcs->blendFuncSeparate) {
- funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
- context->getProcAddress(QLatin1String("glBlendFuncSeparateOES"));
- }
-#endif
- if (!funcs->blendFuncSeparate) {
- funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
- context->getProcAddress(QLatin1String("glBlendFuncSeparateEXT"));
- }
- if (!funcs->blendFuncSeparate) {
- funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
- context->getProcAddress(QLatin1String("glBlendFuncSeparateARB"));
- }
-
- if (funcs->blendFuncSeparate)
- funcs->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
- else
- funcs->blendFuncSeparate = qglfResolveBlendFuncSeparate;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bufferData = (type_glBufferData)
- context->getProcAddress(QLatin1String("glBufferData"));
-#ifdef QT_OPENGL_ES
- if (!funcs->bufferData) {
- funcs->bufferData = (type_glBufferData)
- context->getProcAddress(QLatin1String("glBufferDataOES"));
- }
-#endif
- if (!funcs->bufferData) {
- funcs->bufferData = (type_glBufferData)
- context->getProcAddress(QLatin1String("glBufferDataEXT"));
- }
- if (!funcs->bufferData) {
- funcs->bufferData = (type_glBufferData)
- context->getProcAddress(QLatin1String("glBufferDataARB"));
- }
-
- if (funcs->bufferData)
- funcs->bufferData(target, size, data, usage);
- else
- funcs->bufferData = qglfResolveBufferData;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glBufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->bufferSubData = (type_glBufferSubData)
- context->getProcAddress(QLatin1String("glBufferSubData"));
-#ifdef QT_OPENGL_ES
- if (!funcs->bufferSubData) {
- funcs->bufferSubData = (type_glBufferSubData)
- context->getProcAddress(QLatin1String("glBufferSubDataOES"));
- }
-#endif
- if (!funcs->bufferSubData) {
- funcs->bufferSubData = (type_glBufferSubData)
- context->getProcAddress(QLatin1String("glBufferSubDataEXT"));
- }
- if (!funcs->bufferSubData) {
- funcs->bufferSubData = (type_glBufferSubData)
- context->getProcAddress(QLatin1String("glBufferSubDataARB"));
- }
-
- if (funcs->bufferSubData)
- funcs->bufferSubData(target, offset, size, data);
- else
- funcs->bufferSubData = qglfResolveBufferSubData;
-}
-
-static GLenum QT3D_GLF_APIENTRY qglfResolveCheckFramebufferStatus(GLenum target)
-{
- typedef GLenum (QT3D_GLF_APIENTRYP type_glCheckFramebufferStatus)(GLenum target);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
- context->getProcAddress(QLatin1String("glCheckFramebufferStatus"));
-#ifdef QT_OPENGL_ES
- if (!funcs->checkFramebufferStatus) {
- funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
- context->getProcAddress(QLatin1String("glCheckFramebufferStatusOES"));
- }
-#endif
- if (!funcs->checkFramebufferStatus) {
- funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
- context->getProcAddress(QLatin1String("glCheckFramebufferStatusEXT"));
- }
- if (!funcs->checkFramebufferStatus) {
- funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
- context->getProcAddress(QLatin1String("glCheckFramebufferStatusARB"));
- }
-
- if (funcs->checkFramebufferStatus)
- return funcs->checkFramebufferStatus(target);
- funcs->checkFramebufferStatus = qglfResolveCheckFramebufferStatus;
- return GLenum(0);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveCompileShader(GLuint shader)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glCompileShader)(GLuint shader);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->compileShader = (type_glCompileShader)
- context->getProcAddress(QLatin1String("glCompileShader"));
- if (!funcs->compileShader) {
- funcs->compileShader = (type_glCompileShader)
- context->getProcAddress(QLatin1String("glCompileShader"));
- }
-
- if (funcs->compileShader)
- funcs->compileShader(shader);
- else
- funcs->compileShader = qglfResolveCompileShader;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexImage2D"));
-#ifdef QT_OPENGL_ES
- if (!funcs->compressedTexImage2D) {
- funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexImage2DOES"));
- }
-#endif
- if (!funcs->compressedTexImage2D) {
- funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexImage2DEXT"));
- }
- if (!funcs->compressedTexImage2D) {
- funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexImage2DARB"));
- }
-
- if (funcs->compressedTexImage2D)
- funcs->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
- else
- funcs->compressedTexImage2D = qglfResolveCompressedTexImage2D;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexSubImage2D"));
-#ifdef QT_OPENGL_ES
- if (!funcs->compressedTexSubImage2D) {
- funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexSubImage2DOES"));
- }
-#endif
- if (!funcs->compressedTexSubImage2D) {
- funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexSubImage2DEXT"));
- }
- if (!funcs->compressedTexSubImage2D) {
- funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
- context->getProcAddress(QLatin1String("glCompressedTexSubImage2DARB"));
- }
-
- if (funcs->compressedTexSubImage2D)
- funcs->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
- else
- funcs->compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D;
-}
-
-static GLuint QT3D_GLF_APIENTRY qglfResolveCreateProgram()
-{
- typedef GLuint (QT3D_GLF_APIENTRYP type_glCreateProgram)();
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->createProgram = (type_glCreateProgram)
- context->getProcAddress(QLatin1String("glCreateProgram"));
- if (!funcs->createProgram) {
- funcs->createProgram = (type_glCreateProgram)
- context->getProcAddress(QLatin1String("glCreateProgramObjectARB"));
- }
-
- if (funcs->createProgram)
- return funcs->createProgram();
- funcs->createProgram = qglfResolveCreateProgram;
- return GLuint(0);
-}
-
-static GLuint QT3D_GLF_APIENTRY qglfResolveCreateShader(GLenum type)
-{
- typedef GLuint (QT3D_GLF_APIENTRYP type_glCreateShader)(GLenum type);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->createShader = (type_glCreateShader)
- context->getProcAddress(QLatin1String("glCreateShader"));
- if (!funcs->createShader) {
- funcs->createShader = (type_glCreateShader)
- context->getProcAddress(QLatin1String("glCreateShaderObjectARB"));
- }
-
- if (funcs->createShader)
- return funcs->createShader(type);
- funcs->createShader = qglfResolveCreateShader;
- return GLuint(0);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDeleteBuffers(GLsizei n, const GLuint* buffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDeleteBuffers)(GLsizei n, const GLuint* buffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->deleteBuffers = (type_glDeleteBuffers)
- context->getProcAddress(QLatin1String("glDeleteBuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->deleteBuffers) {
- funcs->deleteBuffers = (type_glDeleteBuffers)
- context->getProcAddress(QLatin1String("glDeleteBuffersOES"));
- }
-#endif
- if (!funcs->deleteBuffers) {
- funcs->deleteBuffers = (type_glDeleteBuffers)
- context->getProcAddress(QLatin1String("glDeleteBuffersEXT"));
- }
- if (!funcs->deleteBuffers) {
- funcs->deleteBuffers = (type_glDeleteBuffers)
- context->getProcAddress(QLatin1String("glDeleteBuffersARB"));
- }
-
- if (funcs->deleteBuffers)
- funcs->deleteBuffers(n, buffers);
- else
- funcs->deleteBuffers = qglfResolveDeleteBuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
- context->getProcAddress(QLatin1String("glDeleteFramebuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->deleteFramebuffers) {
- funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
- context->getProcAddress(QLatin1String("glDeleteFramebuffersOES"));
- }
-#endif
- if (!funcs->deleteFramebuffers) {
- funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
- context->getProcAddress(QLatin1String("glDeleteFramebuffersEXT"));
- }
- if (!funcs->deleteFramebuffers) {
- funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
- context->getProcAddress(QLatin1String("glDeleteFramebuffersARB"));
- }
-
- if (funcs->deleteFramebuffers)
- funcs->deleteFramebuffers(n, framebuffers);
- else
- funcs->deleteFramebuffers = qglfResolveDeleteFramebuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDeleteProgram(GLuint program)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDeleteProgram)(GLuint program);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->deleteProgram = (type_glDeleteProgram)
- context->getProcAddress(QLatin1String("glDeleteProgram"));
- if (!funcs->deleteProgram) {
- funcs->deleteProgram = (type_glDeleteProgram)
- context->getProcAddress(QLatin1String("glDeleteObjectARB"));
- }
-
- if (funcs->deleteProgram)
- funcs->deleteProgram(program);
- else
- funcs->deleteProgram = qglfResolveDeleteProgram;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
- context->getProcAddress(QLatin1String("glDeleteRenderbuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->deleteRenderbuffers) {
- funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
- context->getProcAddress(QLatin1String("glDeleteRenderbuffersOES"));
- }
-#endif
- if (!funcs->deleteRenderbuffers) {
- funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
- context->getProcAddress(QLatin1String("glDeleteRenderbuffersEXT"));
- }
- if (!funcs->deleteRenderbuffers) {
- funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
- context->getProcAddress(QLatin1String("glDeleteRenderbuffersARB"));
- }
-
- if (funcs->deleteRenderbuffers)
- funcs->deleteRenderbuffers(n, renderbuffers);
- else
- funcs->deleteRenderbuffers = qglfResolveDeleteRenderbuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDeleteShader(GLuint shader)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDeleteShader)(GLuint shader);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->deleteShader = (type_glDeleteShader)
- context->getProcAddress(QLatin1String("glDeleteShader"));
- if (!funcs->deleteShader) {
- funcs->deleteShader = (type_glDeleteShader)
- context->getProcAddress(QLatin1String("glDeleteObjectARB"));
- }
-
- if (funcs->deleteShader)
- funcs->deleteShader(shader);
- else
- funcs->deleteShader = qglfResolveDeleteShader;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDetachShader(GLuint program, GLuint shader)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDetachShader)(GLuint program, GLuint shader);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->detachShader = (type_glDetachShader)
- context->getProcAddress(QLatin1String("glDetachShader"));
- if (!funcs->detachShader) {
- funcs->detachShader = (type_glDetachShader)
- context->getProcAddress(QLatin1String("glDetachObjectARB"));
- }
-
- if (funcs->detachShader)
- funcs->detachShader(program, shader);
- else
- funcs->detachShader = qglfResolveDetachShader;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveDisableVertexAttribArray(GLuint index)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glDisableVertexAttribArray)(GLuint index);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray)
- context->getProcAddress(QLatin1String("glDisableVertexAttribArray"));
- if (!funcs->disableVertexAttribArray) {
- funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray)
- context->getProcAddress(QLatin1String("glDisableVertexAttribArrayARB"));
- }
-
- if (funcs->disableVertexAttribArray)
- funcs->disableVertexAttribArray(index);
- else
- funcs->disableVertexAttribArray = qglfResolveDisableVertexAttribArray;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveEnableVertexAttribArray(GLuint index)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glEnableVertexAttribArray)(GLuint index);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray)
- context->getProcAddress(QLatin1String("glEnableVertexAttribArray"));
- if (!funcs->enableVertexAttribArray) {
- funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray)
- context->getProcAddress(QLatin1String("glEnableVertexAttribArrayARB"));
- }
-
- if (funcs->enableVertexAttribArray)
- funcs->enableVertexAttribArray(index);
- else
- funcs->enableVertexAttribArray = qglfResolveEnableVertexAttribArray;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
- context->getProcAddress(QLatin1String("glFramebufferRenderbuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->framebufferRenderbuffer) {
- funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
- context->getProcAddress(QLatin1String("glFramebufferRenderbufferOES"));
- }
-#endif
- if (!funcs->framebufferRenderbuffer) {
- funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
- context->getProcAddress(QLatin1String("glFramebufferRenderbufferEXT"));
- }
- if (!funcs->framebufferRenderbuffer) {
- funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
- context->getProcAddress(QLatin1String("glFramebufferRenderbufferARB"));
- }
-
- if (funcs->framebufferRenderbuffer)
- funcs->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
- else
- funcs->framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
- context->getProcAddress(QLatin1String("glFramebufferTexture2D"));
-#ifdef QT_OPENGL_ES
- if (!funcs->framebufferTexture2D) {
- funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
- context->getProcAddress(QLatin1String("glFramebufferTexture2DOES"));
- }
-#endif
- if (!funcs->framebufferTexture2D) {
- funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
- context->getProcAddress(QLatin1String("glFramebufferTexture2DEXT"));
- }
- if (!funcs->framebufferTexture2D) {
- funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
- context->getProcAddress(QLatin1String("glFramebufferTexture2DARB"));
- }
-
- if (funcs->framebufferTexture2D)
- funcs->framebufferTexture2D(target, attachment, textarget, texture, level);
- else
- funcs->framebufferTexture2D = qglfResolveFramebufferTexture2D;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGenBuffers(GLsizei n, GLuint* buffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGenBuffers)(GLsizei n, GLuint* buffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->genBuffers = (type_glGenBuffers)
- context->getProcAddress(QLatin1String("glGenBuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->genBuffers) {
- funcs->genBuffers = (type_glGenBuffers)
- context->getProcAddress(QLatin1String("glGenBuffersOES"));
- }
-#endif
- if (!funcs->genBuffers) {
- funcs->genBuffers = (type_glGenBuffers)
- context->getProcAddress(QLatin1String("glGenBuffersEXT"));
- }
- if (!funcs->genBuffers) {
- funcs->genBuffers = (type_glGenBuffers)
- context->getProcAddress(QLatin1String("glGenBuffersARB"));
- }
-
- if (funcs->genBuffers)
- funcs->genBuffers(n, buffers);
- else
- funcs->genBuffers = qglfResolveGenBuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGenerateMipmap(GLenum target)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGenerateMipmap)(GLenum target);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->generateMipmap = (type_glGenerateMipmap)
- context->getProcAddress(QLatin1String("glGenerateMipmap"));
-#ifdef QT_OPENGL_ES
- if (!funcs->generateMipmap) {
- funcs->generateMipmap = (type_glGenerateMipmap)
- context->getProcAddress(QLatin1String("glGenerateMipmapOES"));
- }
-#endif
- if (!funcs->generateMipmap) {
- funcs->generateMipmap = (type_glGenerateMipmap)
- context->getProcAddress(QLatin1String("glGenerateMipmapEXT"));
- }
- if (!funcs->generateMipmap) {
- funcs->generateMipmap = (type_glGenerateMipmap)
- context->getProcAddress(QLatin1String("glGenerateMipmapARB"));
- }
-
- if (funcs->generateMipmap)
- funcs->generateMipmap(target);
- else
- funcs->generateMipmap = qglfResolveGenerateMipmap;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGenFramebuffers(GLsizei n, GLuint* framebuffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGenFramebuffers)(GLsizei n, GLuint* framebuffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->genFramebuffers = (type_glGenFramebuffers)
- context->getProcAddress(QLatin1String("glGenFramebuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->genFramebuffers) {
- funcs->genFramebuffers = (type_glGenFramebuffers)
- context->getProcAddress(QLatin1String("glGenFramebuffersOES"));
- }
-#endif
- if (!funcs->genFramebuffers) {
- funcs->genFramebuffers = (type_glGenFramebuffers)
- context->getProcAddress(QLatin1String("glGenFramebuffersEXT"));
- }
- if (!funcs->genFramebuffers) {
- funcs->genFramebuffers = (type_glGenFramebuffers)
- context->getProcAddress(QLatin1String("glGenFramebuffersARB"));
- }
-
- if (funcs->genFramebuffers)
- funcs->genFramebuffers(n, framebuffers);
- else
- funcs->genFramebuffers = qglfResolveGenFramebuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->genRenderbuffers = (type_glGenRenderbuffers)
- context->getProcAddress(QLatin1String("glGenRenderbuffers"));
-#ifdef QT_OPENGL_ES
- if (!funcs->genRenderbuffers) {
- funcs->genRenderbuffers = (type_glGenRenderbuffers)
- context->getProcAddress(QLatin1String("glGenRenderbuffersOES"));
- }
-#endif
- if (!funcs->genRenderbuffers) {
- funcs->genRenderbuffers = (type_glGenRenderbuffers)
- context->getProcAddress(QLatin1String("glGenRenderbuffersEXT"));
- }
- if (!funcs->genRenderbuffers) {
- funcs->genRenderbuffers = (type_glGenRenderbuffers)
- context->getProcAddress(QLatin1String("glGenRenderbuffersARB"));
- }
-
- if (funcs->genRenderbuffers)
- funcs->genRenderbuffers(n, renderbuffers);
- else
- funcs->genRenderbuffers = qglfResolveGenRenderbuffers;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getActiveAttrib = (type_glGetActiveAttrib)
- context->getProcAddress(QLatin1String("glGetActiveAttrib"));
- if (!funcs->getActiveAttrib) {
- funcs->getActiveAttrib = (type_glGetActiveAttrib)
- context->getProcAddress(QLatin1String("glGetActiveAttribARB"));
- }
-
- if (funcs->getActiveAttrib)
- funcs->getActiveAttrib(program, index, bufsize, length, size, type, name);
- else
- funcs->getActiveAttrib = qglfResolveGetActiveAttrib;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getActiveUniform = (type_glGetActiveUniform)
- context->getProcAddress(QLatin1String("glGetActiveUniform"));
- if (!funcs->getActiveUniform) {
- funcs->getActiveUniform = (type_glGetActiveUniform)
- context->getProcAddress(QLatin1String("glGetActiveUniformARB"));
- }
-
- if (funcs->getActiveUniform)
- funcs->getActiveUniform(program, index, bufsize, length, size, type, name);
- else
- funcs->getActiveUniform = qglfResolveGetActiveUniform;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getAttachedShaders = (type_glGetAttachedShaders)
- context->getProcAddress(QLatin1String("glGetAttachedShaders"));
- if (!funcs->getAttachedShaders) {
- funcs->getAttachedShaders = (type_glGetAttachedShaders)
- context->getProcAddress(QLatin1String("glGetAttachedObjectsARB"));
- }
-
- if (funcs->getAttachedShaders)
- funcs->getAttachedShaders(program, maxcount, count, shaders);
- else
- funcs->getAttachedShaders = qglfResolveGetAttachedShaders;
-}
-
-static int QT3D_GLF_APIENTRY qglfResolveGetAttribLocation(GLuint program, const char* name)
-{
- typedef int (QT3D_GLF_APIENTRYP type_glGetAttribLocation)(GLuint program, const char* name);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getAttribLocation = (type_glGetAttribLocation)
- context->getProcAddress(QLatin1String("glGetAttribLocation"));
- if (!funcs->getAttribLocation) {
- funcs->getAttribLocation = (type_glGetAttribLocation)
- context->getProcAddress(QLatin1String("glGetAttribLocationARB"));
- }
-
- if (funcs->getAttribLocation)
- return funcs->getAttribLocation(program, name);
- funcs->getAttribLocation = qglfResolveGetAttribLocation;
- return int(0);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
- context->getProcAddress(QLatin1String("glGetBufferParameteriv"));
-#ifdef QT_OPENGL_ES
- if (!funcs->getBufferParameteriv) {
- funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
- context->getProcAddress(QLatin1String("glGetBufferParameterivOES"));
- }
-#endif
- if (!funcs->getBufferParameteriv) {
- funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
- context->getProcAddress(QLatin1String("glGetBufferParameterivEXT"));
- }
- if (!funcs->getBufferParameteriv) {
- funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
- context->getProcAddress(QLatin1String("glGetBufferParameterivARB"));
- }
-
- if (funcs->getBufferParameteriv)
- funcs->getBufferParameteriv(target, pname, params);
- else
- funcs->getBufferParameteriv = qglfResolveGetBufferParameteriv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
- context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameteriv"));
-#ifdef QT_OPENGL_ES
- if (!funcs->getFramebufferAttachmentParameteriv) {
- funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
- context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivOES"));
- }
-#endif
- if (!funcs->getFramebufferAttachmentParameteriv) {
- funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
- context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivEXT"));
- }
- if (!funcs->getFramebufferAttachmentParameteriv) {
- funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
- context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivARB"));
- }
-
- if (funcs->getFramebufferAttachmentParameteriv)
- funcs->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
- else
- funcs->getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetProgramiv(GLuint program, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetProgramiv)(GLuint program, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getProgramiv = (type_glGetProgramiv)
- context->getProcAddress(QLatin1String("glGetProgramiv"));
- if (!funcs->getProgramiv) {
- funcs->getProgramiv = (type_glGetProgramiv)
- context->getProcAddress(QLatin1String("glGetObjectParameterivARB"));
- }
-
- if (funcs->getProgramiv)
- funcs->getProgramiv(program, pname, params);
- else
- funcs->getProgramiv = qglfResolveGetProgramiv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getProgramInfoLog = (type_glGetProgramInfoLog)
- context->getProcAddress(QLatin1String("glGetProgramInfoLog"));
- if (!funcs->getProgramInfoLog) {
- funcs->getProgramInfoLog = (type_glGetProgramInfoLog)
- context->getProcAddress(QLatin1String("glGetInfoLogARB"));
- }
-
- if (funcs->getProgramInfoLog)
- funcs->getProgramInfoLog(program, bufsize, length, infolog);
- else
- funcs->getProgramInfoLog = qglfResolveGetProgramInfoLog;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
- context->getProcAddress(QLatin1String("glGetRenderbufferParameteriv"));
-#ifdef QT_OPENGL_ES
- if (!funcs->getRenderbufferParameteriv) {
- funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
- context->getProcAddress(QLatin1String("glGetRenderbufferParameterivOES"));
- }
-#endif
- if (!funcs->getRenderbufferParameteriv) {
- funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
- context->getProcAddress(QLatin1String("glGetRenderbufferParameterivEXT"));
- }
- if (!funcs->getRenderbufferParameteriv) {
- funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
- context->getProcAddress(QLatin1String("glGetRenderbufferParameterivARB"));
- }
-
- if (funcs->getRenderbufferParameteriv)
- funcs->getRenderbufferParameteriv(target, pname, params);
- else
- funcs->getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetShaderiv(GLuint shader, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetShaderiv)(GLuint shader, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getShaderiv = (type_glGetShaderiv)
- context->getProcAddress(QLatin1String("glGetShaderiv"));
- if (!funcs->getShaderiv) {
- funcs->getShaderiv = (type_glGetShaderiv)
- context->getProcAddress(QLatin1String("glGetObjectParameterivARB"));
- }
-
- if (funcs->getShaderiv)
- funcs->getShaderiv(shader, pname, params);
- else
- funcs->getShaderiv = qglfResolveGetShaderiv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getShaderInfoLog = (type_glGetShaderInfoLog)
- context->getProcAddress(QLatin1String("glGetShaderInfoLog"));
- if (!funcs->getShaderInfoLog) {
- funcs->getShaderInfoLog = (type_glGetShaderInfoLog)
- context->getProcAddress(QLatin1String("glGetInfoLogARB"));
- }
-
- if (funcs->getShaderInfoLog)
- funcs->getShaderInfoLog(shader, bufsize, length, infolog);
- else
- funcs->getShaderInfoLog = qglfResolveGetShaderInfoLog;
-}
-
-static void QT3D_GLF_APIENTRY qglfSpecialGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-{
- Q_UNUSED(shadertype);
- Q_UNUSED(precisiontype);
- range[0] = range[1] = precision[0] = 0;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
- context->getProcAddress(QLatin1String("glGetShaderPrecisionFormat"));
-#ifdef QT_OPENGL_ES
- if (!funcs->getShaderPrecisionFormat) {
- funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
- context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatOES"));
- }
-#endif
- if (!funcs->getShaderPrecisionFormat) {
- funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
- context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatEXT"));
- }
- if (!funcs->getShaderPrecisionFormat) {
- funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
- context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatARB"));
- }
-
- if (!funcs->getShaderPrecisionFormat)
- funcs->getShaderPrecisionFormat = qglfSpecialGetShaderPrecisionFormat;
-
- funcs->getShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getShaderSource = (type_glGetShaderSource)
- context->getProcAddress(QLatin1String("glGetShaderSource"));
- if (!funcs->getShaderSource) {
- funcs->getShaderSource = (type_glGetShaderSource)
- context->getProcAddress(QLatin1String("glGetShaderSourceARB"));
- }
-
- if (funcs->getShaderSource)
- funcs->getShaderSource(shader, bufsize, length, source);
- else
- funcs->getShaderSource = qglfResolveGetShaderSource;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetUniformfv(GLuint program, GLint location, GLfloat* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetUniformfv)(GLuint program, GLint location, GLfloat* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getUniformfv = (type_glGetUniformfv)
- context->getProcAddress(QLatin1String("glGetUniformfv"));
- if (!funcs->getUniformfv) {
- funcs->getUniformfv = (type_glGetUniformfv)
- context->getProcAddress(QLatin1String("glGetUniformfvARB"));
- }
-
- if (funcs->getUniformfv)
- funcs->getUniformfv(program, location, params);
- else
- funcs->getUniformfv = qglfResolveGetUniformfv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetUniformiv(GLuint program, GLint location, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetUniformiv)(GLuint program, GLint location, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getUniformiv = (type_glGetUniformiv)
- context->getProcAddress(QLatin1String("glGetUniformiv"));
- if (!funcs->getUniformiv) {
- funcs->getUniformiv = (type_glGetUniformiv)
- context->getProcAddress(QLatin1String("glGetUniformivARB"));
- }
-
- if (funcs->getUniformiv)
- funcs->getUniformiv(program, location, params);
- else
- funcs->getUniformiv = qglfResolveGetUniformiv;
-}
-
-static int QT3D_GLF_APIENTRY qglfResolveGetUniformLocation(GLuint program, const char* name)
-{
- typedef int (QT3D_GLF_APIENTRYP type_glGetUniformLocation)(GLuint program, const char* name);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getUniformLocation = (type_glGetUniformLocation)
- context->getProcAddress(QLatin1String("glGetUniformLocation"));
- if (!funcs->getUniformLocation) {
- funcs->getUniformLocation = (type_glGetUniformLocation)
- context->getProcAddress(QLatin1String("glGetUniformLocationARB"));
- }
-
- if (funcs->getUniformLocation)
- return funcs->getUniformLocation(program, name);
- funcs->getUniformLocation = qglfResolveGetUniformLocation;
- return int(0);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getVertexAttribfv = (type_glGetVertexAttribfv)
- context->getProcAddress(QLatin1String("glGetVertexAttribfv"));
- if (!funcs->getVertexAttribfv) {
- funcs->getVertexAttribfv = (type_glGetVertexAttribfv)
- context->getProcAddress(QLatin1String("glGetVertexAttribfvARB"));
- }
-
- if (funcs->getVertexAttribfv)
- funcs->getVertexAttribfv(index, pname, params);
- else
- funcs->getVertexAttribfv = qglfResolveGetVertexAttribfv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getVertexAttribiv = (type_glGetVertexAttribiv)
- context->getProcAddress(QLatin1String("glGetVertexAttribiv"));
- if (!funcs->getVertexAttribiv) {
- funcs->getVertexAttribiv = (type_glGetVertexAttribiv)
- context->getProcAddress(QLatin1String("glGetVertexAttribivARB"));
- }
-
- if (funcs->getVertexAttribiv)
- funcs->getVertexAttribiv(index, pname, params);
- else
- funcs->getVertexAttribiv = qglfResolveGetVertexAttribiv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv)
- context->getProcAddress(QLatin1String("glGetVertexAttribPointerv"));
- if (!funcs->getVertexAttribPointerv) {
- funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv)
- context->getProcAddress(QLatin1String("glGetVertexAttribPointervARB"));
- }
-
- if (funcs->getVertexAttribPointerv)
- funcs->getVertexAttribPointerv(index, pname, pointer);
- else
- funcs->getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv;
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfResolveIsBuffer(GLuint buffer)
-{
- typedef GLboolean (QT3D_GLF_APIENTRYP type_glIsBuffer)(GLuint buffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->isBuffer = (type_glIsBuffer)
- context->getProcAddress(QLatin1String("glIsBuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->isBuffer) {
- funcs->isBuffer = (type_glIsBuffer)
- context->getProcAddress(QLatin1String("glIsBufferOES"));
- }
-#endif
- if (!funcs->isBuffer) {
- funcs->isBuffer = (type_glIsBuffer)
- context->getProcAddress(QLatin1String("glIsBufferEXT"));
- }
- if (!funcs->isBuffer) {
- funcs->isBuffer = (type_glIsBuffer)
- context->getProcAddress(QLatin1String("glIsBufferARB"));
- }
-
- if (funcs->isBuffer)
- return funcs->isBuffer(buffer);
- funcs->isBuffer = qglfResolveIsBuffer;
- return GLboolean(0);
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfResolveIsFramebuffer(GLuint framebuffer)
-{
- typedef GLboolean (QT3D_GLF_APIENTRYP type_glIsFramebuffer)(GLuint framebuffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->isFramebuffer = (type_glIsFramebuffer)
- context->getProcAddress(QLatin1String("glIsFramebuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->isFramebuffer) {
- funcs->isFramebuffer = (type_glIsFramebuffer)
- context->getProcAddress(QLatin1String("glIsFramebufferOES"));
- }
-#endif
- if (!funcs->isFramebuffer) {
- funcs->isFramebuffer = (type_glIsFramebuffer)
- context->getProcAddress(QLatin1String("glIsFramebufferEXT"));
- }
- if (!funcs->isFramebuffer) {
- funcs->isFramebuffer = (type_glIsFramebuffer)
- context->getProcAddress(QLatin1String("glIsFramebufferARB"));
- }
-
- if (funcs->isFramebuffer)
- return funcs->isFramebuffer(framebuffer);
- funcs->isFramebuffer = qglfResolveIsFramebuffer;
- return GLboolean(0);
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfSpecialIsProgram(GLuint program)
-{
- return program != 0;
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfResolveIsProgram(GLuint program)
-{
- typedef GLboolean (QT3D_GLF_APIENTRYP type_glIsProgram)(GLuint program);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->isProgram = (type_glIsProgram)
- context->getProcAddress(QLatin1String("glIsProgram"));
- if (!funcs->isProgram) {
- funcs->isProgram = (type_glIsProgram)
- context->getProcAddress(QLatin1String("glIsProgramARB"));
- }
-
- if (!funcs->isProgram)
- funcs->isProgram = qglfSpecialIsProgram;
-
- return funcs->isProgram(program);
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfResolveIsRenderbuffer(GLuint renderbuffer)
-{
- typedef GLboolean (QT3D_GLF_APIENTRYP type_glIsRenderbuffer)(GLuint renderbuffer);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->isRenderbuffer = (type_glIsRenderbuffer)
- context->getProcAddress(QLatin1String("glIsRenderbuffer"));
-#ifdef QT_OPENGL_ES
- if (!funcs->isRenderbuffer) {
- funcs->isRenderbuffer = (type_glIsRenderbuffer)
- context->getProcAddress(QLatin1String("glIsRenderbufferOES"));
- }
-#endif
- if (!funcs->isRenderbuffer) {
- funcs->isRenderbuffer = (type_glIsRenderbuffer)
- context->getProcAddress(QLatin1String("glIsRenderbufferEXT"));
- }
- if (!funcs->isRenderbuffer) {
- funcs->isRenderbuffer = (type_glIsRenderbuffer)
- context->getProcAddress(QLatin1String("glIsRenderbufferARB"));
- }
-
- if (funcs->isRenderbuffer)
- return funcs->isRenderbuffer(renderbuffer);
- funcs->isRenderbuffer = qglfResolveIsRenderbuffer;
- return GLboolean(0);
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfSpecialIsShader(GLuint shader)
-{
- return shader != 0;
-}
-
-static GLboolean QT3D_GLF_APIENTRY qglfResolveIsShader(GLuint shader)
-{
- typedef GLboolean (QT3D_GLF_APIENTRYP type_glIsShader)(GLuint shader);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->isShader = (type_glIsShader)
- context->getProcAddress(QLatin1String("glIsShader"));
- if (!funcs->isShader) {
- funcs->isShader = (type_glIsShader)
- context->getProcAddress(QLatin1String("glIsShaderARB"));
- }
-
- if (!funcs->isShader)
- funcs->isShader = qglfSpecialIsShader;
-
- return funcs->isShader(shader);
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveLinkProgram(GLuint program)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glLinkProgram)(GLuint program);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->linkProgram = (type_glLinkProgram)
- context->getProcAddress(QLatin1String("glLinkProgram"));
- if (!funcs->linkProgram) {
- funcs->linkProgram = (type_glLinkProgram)
- context->getProcAddress(QLatin1String("glLinkProgramARB"));
- }
-
- if (funcs->linkProgram)
- funcs->linkProgram(program);
- else
- funcs->linkProgram = qglfResolveLinkProgram;
-}
-
-static void QT3D_GLF_APIENTRY qglfSpecialReleaseShaderCompiler()
-{
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveReleaseShaderCompiler()
-{
- typedef void (QT3D_GLF_APIENTRYP type_glReleaseShaderCompiler)();
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler)
- context->getProcAddress(QLatin1String("glReleaseShaderCompiler"));
- if (!funcs->releaseShaderCompiler) {
- funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler)
- context->getProcAddress(QLatin1String("glReleaseShaderCompilerARB"));
- }
-
- if (!funcs->releaseShaderCompiler)
- funcs->releaseShaderCompiler = qglfSpecialReleaseShaderCompiler;
-
- funcs->releaseShaderCompiler();
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->renderbufferStorage = (type_glRenderbufferStorage)
- context->getProcAddress(QLatin1String("glRenderbufferStorage"));
-#ifdef QT_OPENGL_ES
- if (!funcs->renderbufferStorage) {
- funcs->renderbufferStorage = (type_glRenderbufferStorage)
- context->getProcAddress(QLatin1String("glRenderbufferStorageOES"));
- }
-#endif
- if (!funcs->renderbufferStorage) {
- funcs->renderbufferStorage = (type_glRenderbufferStorage)
- context->getProcAddress(QLatin1String("glRenderbufferStorageEXT"));
- }
- if (!funcs->renderbufferStorage) {
- funcs->renderbufferStorage = (type_glRenderbufferStorage)
- context->getProcAddress(QLatin1String("glRenderbufferStorageARB"));
- }
-
- if (funcs->renderbufferStorage)
- funcs->renderbufferStorage(target, internalformat, width, height);
- else
- funcs->renderbufferStorage = qglfResolveRenderbufferStorage;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveSampleCoverage(GLclampf value, GLboolean invert)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glSampleCoverage)(GLclampf value, GLboolean invert);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->sampleCoverage = (type_glSampleCoverage)
- context->getProcAddress(QLatin1String("glSampleCoverage"));
-#ifdef QT_OPENGL_ES
- if (!funcs->sampleCoverage) {
- funcs->sampleCoverage = (type_glSampleCoverage)
- context->getProcAddress(QLatin1String("glSampleCoverageOES"));
- }
-#endif
- if (!funcs->sampleCoverage) {
- funcs->sampleCoverage = (type_glSampleCoverage)
- context->getProcAddress(QLatin1String("glSampleCoverageEXT"));
- }
- if (!funcs->sampleCoverage) {
- funcs->sampleCoverage = (type_glSampleCoverage)
- context->getProcAddress(QLatin1String("glSampleCoverageARB"));
- }
-
- if (funcs->sampleCoverage)
- funcs->sampleCoverage(value, invert);
- else
- funcs->sampleCoverage = qglfResolveSampleCoverage;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glShaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->shaderBinary = (type_glShaderBinary)
- context->getProcAddress(QLatin1String("glShaderBinary"));
- if (!funcs->shaderBinary) {
- funcs->shaderBinary = (type_glShaderBinary)
- context->getProcAddress(QLatin1String("glShaderBinaryARB"));
- }
-
- if (funcs->shaderBinary)
- funcs->shaderBinary(n, shaders, binaryformat, binary, length);
- else
- funcs->shaderBinary = qglfResolveShaderBinary;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glShaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->shaderSource = (type_glShaderSource)
- context->getProcAddress(QLatin1String("glShaderSource"));
- if (!funcs->shaderSource) {
- funcs->shaderSource = (type_glShaderSource)
- context->getProcAddress(QLatin1String("glShaderSourceARB"));
- }
-
- if (funcs->shaderSource)
- funcs->shaderSource(shader, count, string, length);
- else
- funcs->shaderSource = qglfResolveShaderSource;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
- context->getProcAddress(QLatin1String("glStencilFuncSeparate"));
-#ifdef QT_OPENGL_ES
- if (!funcs->stencilFuncSeparate) {
- funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
- context->getProcAddress(QLatin1String("glStencilFuncSeparateOES"));
- }
-#endif
- if (!funcs->stencilFuncSeparate) {
- funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
- context->getProcAddress(QLatin1String("glStencilFuncSeparateEXT"));
- }
- if (!funcs->stencilFuncSeparate) {
- funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
- context->getProcAddress(QLatin1String("glStencilFuncSeparateARB"));
- }
-
- if (funcs->stencilFuncSeparate)
- funcs->stencilFuncSeparate(face, func, ref, mask);
- else
- funcs->stencilFuncSeparate = qglfResolveStencilFuncSeparate;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveStencilMaskSeparate(GLenum face, GLuint mask)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glStencilMaskSeparate)(GLenum face, GLuint mask);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
- context->getProcAddress(QLatin1String("glStencilMaskSeparate"));
-#ifdef QT_OPENGL_ES
- if (!funcs->stencilMaskSeparate) {
- funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
- context->getProcAddress(QLatin1String("glStencilMaskSeparateOES"));
- }
-#endif
- if (!funcs->stencilMaskSeparate) {
- funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
- context->getProcAddress(QLatin1String("glStencilMaskSeparateEXT"));
- }
- if (!funcs->stencilMaskSeparate) {
- funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
- context->getProcAddress(QLatin1String("glStencilMaskSeparateARB"));
- }
-
- if (funcs->stencilMaskSeparate)
- funcs->stencilMaskSeparate(face, mask);
- else
- funcs->stencilMaskSeparate = qglfResolveStencilMaskSeparate;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->stencilOpSeparate = (type_glStencilOpSeparate)
- context->getProcAddress(QLatin1String("glStencilOpSeparate"));
-#ifdef QT_OPENGL_ES
- if (!funcs->stencilOpSeparate) {
- funcs->stencilOpSeparate = (type_glStencilOpSeparate)
- context->getProcAddress(QLatin1String("glStencilOpSeparateOES"));
- }
-#endif
- if (!funcs->stencilOpSeparate) {
- funcs->stencilOpSeparate = (type_glStencilOpSeparate)
- context->getProcAddress(QLatin1String("glStencilOpSeparateEXT"));
- }
- if (!funcs->stencilOpSeparate) {
- funcs->stencilOpSeparate = (type_glStencilOpSeparate)
- context->getProcAddress(QLatin1String("glStencilOpSeparateARB"));
- }
-
- if (funcs->stencilOpSeparate)
- funcs->stencilOpSeparate(face, fail, zfail, zpass);
- else
- funcs->stencilOpSeparate = qglfResolveStencilOpSeparate;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform1f(GLint location, GLfloat x)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform1f)(GLint location, GLfloat x);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform1f = (type_glUniform1f)
- context->getProcAddress(QLatin1String("glUniform1f"));
- if (!funcs->uniform1f) {
- funcs->uniform1f = (type_glUniform1f)
- context->getProcAddress(QLatin1String("glUniform1fARB"));
- }
-
- if (funcs->uniform1f)
- funcs->uniform1f(location, x);
- else
- funcs->uniform1f = qglfResolveUniform1f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform1fv(GLint location, GLsizei count, const GLfloat* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform1fv)(GLint location, GLsizei count, const GLfloat* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform1fv = (type_glUniform1fv)
- context->getProcAddress(QLatin1String("glUniform1fv"));
- if (!funcs->uniform1fv) {
- funcs->uniform1fv = (type_glUniform1fv)
- context->getProcAddress(QLatin1String("glUniform1fvARB"));
- }
-
- if (funcs->uniform1fv)
- funcs->uniform1fv(location, count, v);
- else
- funcs->uniform1fv = qglfResolveUniform1fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform1i(GLint location, GLint x)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform1i)(GLint location, GLint x);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform1i = (type_glUniform1i)
- context->getProcAddress(QLatin1String("glUniform1i"));
- if (!funcs->uniform1i) {
- funcs->uniform1i = (type_glUniform1i)
- context->getProcAddress(QLatin1String("glUniform1iARB"));
- }
-
- if (funcs->uniform1i)
- funcs->uniform1i(location, x);
- else
- funcs->uniform1i = qglfResolveUniform1i;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform1iv(GLint location, GLsizei count, const GLint* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform1iv)(GLint location, GLsizei count, const GLint* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform1iv = (type_glUniform1iv)
- context->getProcAddress(QLatin1String("glUniform1iv"));
- if (!funcs->uniform1iv) {
- funcs->uniform1iv = (type_glUniform1iv)
- context->getProcAddress(QLatin1String("glUniform1ivARB"));
- }
-
- if (funcs->uniform1iv)
- funcs->uniform1iv(location, count, v);
- else
- funcs->uniform1iv = qglfResolveUniform1iv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform2f(GLint location, GLfloat x, GLfloat y)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform2f)(GLint location, GLfloat x, GLfloat y);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform2f = (type_glUniform2f)
- context->getProcAddress(QLatin1String("glUniform2f"));
- if (!funcs->uniform2f) {
- funcs->uniform2f = (type_glUniform2f)
- context->getProcAddress(QLatin1String("glUniform2fARB"));
- }
-
- if (funcs->uniform2f)
- funcs->uniform2f(location, x, y);
- else
- funcs->uniform2f = qglfResolveUniform2f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform2fv(GLint location, GLsizei count, const GLfloat* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform2fv)(GLint location, GLsizei count, const GLfloat* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform2fv = (type_glUniform2fv)
- context->getProcAddress(QLatin1String("glUniform2fv"));
- if (!funcs->uniform2fv) {
- funcs->uniform2fv = (type_glUniform2fv)
- context->getProcAddress(QLatin1String("glUniform2fvARB"));
- }
-
- if (funcs->uniform2fv)
- funcs->uniform2fv(location, count, v);
- else
- funcs->uniform2fv = qglfResolveUniform2fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform2i(GLint location, GLint x, GLint y)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform2i)(GLint location, GLint x, GLint y);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform2i = (type_glUniform2i)
- context->getProcAddress(QLatin1String("glUniform2i"));
- if (!funcs->uniform2i) {
- funcs->uniform2i = (type_glUniform2i)
- context->getProcAddress(QLatin1String("glUniform2iARB"));
- }
-
- if (funcs->uniform2i)
- funcs->uniform2i(location, x, y);
- else
- funcs->uniform2i = qglfResolveUniform2i;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform2iv(GLint location, GLsizei count, const GLint* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform2iv)(GLint location, GLsizei count, const GLint* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform2iv = (type_glUniform2iv)
- context->getProcAddress(QLatin1String("glUniform2iv"));
- if (!funcs->uniform2iv) {
- funcs->uniform2iv = (type_glUniform2iv)
- context->getProcAddress(QLatin1String("glUniform2ivARB"));
- }
-
- if (funcs->uniform2iv)
- funcs->uniform2iv(location, count, v);
- else
- funcs->uniform2iv = qglfResolveUniform2iv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform3f = (type_glUniform3f)
- context->getProcAddress(QLatin1String("glUniform3f"));
- if (!funcs->uniform3f) {
- funcs->uniform3f = (type_glUniform3f)
- context->getProcAddress(QLatin1String("glUniform3fARB"));
- }
-
- if (funcs->uniform3f)
- funcs->uniform3f(location, x, y, z);
- else
- funcs->uniform3f = qglfResolveUniform3f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform3fv(GLint location, GLsizei count, const GLfloat* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform3fv)(GLint location, GLsizei count, const GLfloat* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform3fv = (type_glUniform3fv)
- context->getProcAddress(QLatin1String("glUniform3fv"));
- if (!funcs->uniform3fv) {
- funcs->uniform3fv = (type_glUniform3fv)
- context->getProcAddress(QLatin1String("glUniform3fvARB"));
- }
-
- if (funcs->uniform3fv)
- funcs->uniform3fv(location, count, v);
- else
- funcs->uniform3fv = qglfResolveUniform3fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform3i(GLint location, GLint x, GLint y, GLint z)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform3i)(GLint location, GLint x, GLint y, GLint z);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform3i = (type_glUniform3i)
- context->getProcAddress(QLatin1String("glUniform3i"));
- if (!funcs->uniform3i) {
- funcs->uniform3i = (type_glUniform3i)
- context->getProcAddress(QLatin1String("glUniform3iARB"));
- }
-
- if (funcs->uniform3i)
- funcs->uniform3i(location, x, y, z);
- else
- funcs->uniform3i = qglfResolveUniform3i;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform3iv(GLint location, GLsizei count, const GLint* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform3iv)(GLint location, GLsizei count, const GLint* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform3iv = (type_glUniform3iv)
- context->getProcAddress(QLatin1String("glUniform3iv"));
- if (!funcs->uniform3iv) {
- funcs->uniform3iv = (type_glUniform3iv)
- context->getProcAddress(QLatin1String("glUniform3ivARB"));
- }
-
- if (funcs->uniform3iv)
- funcs->uniform3iv(location, count, v);
- else
- funcs->uniform3iv = qglfResolveUniform3iv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform4f = (type_glUniform4f)
- context->getProcAddress(QLatin1String("glUniform4f"));
- if (!funcs->uniform4f) {
- funcs->uniform4f = (type_glUniform4f)
- context->getProcAddress(QLatin1String("glUniform4fARB"));
- }
-
- if (funcs->uniform4f)
- funcs->uniform4f(location, x, y, z, w);
- else
- funcs->uniform4f = qglfResolveUniform4f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform4fv(GLint location, GLsizei count, const GLfloat* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform4fv)(GLint location, GLsizei count, const GLfloat* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform4fv = (type_glUniform4fv)
- context->getProcAddress(QLatin1String("glUniform4fv"));
- if (!funcs->uniform4fv) {
- funcs->uniform4fv = (type_glUniform4fv)
- context->getProcAddress(QLatin1String("glUniform4fvARB"));
- }
-
- if (funcs->uniform4fv)
- funcs->uniform4fv(location, count, v);
- else
- funcs->uniform4fv = qglfResolveUniform4fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform4i = (type_glUniform4i)
- context->getProcAddress(QLatin1String("glUniform4i"));
- if (!funcs->uniform4i) {
- funcs->uniform4i = (type_glUniform4i)
- context->getProcAddress(QLatin1String("glUniform4iARB"));
- }
-
- if (funcs->uniform4i)
- funcs->uniform4i(location, x, y, z, w);
- else
- funcs->uniform4i = qglfResolveUniform4i;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniform4iv(GLint location, GLsizei count, const GLint* v)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniform4iv)(GLint location, GLsizei count, const GLint* v);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniform4iv = (type_glUniform4iv)
- context->getProcAddress(QLatin1String("glUniform4iv"));
- if (!funcs->uniform4iv) {
- funcs->uniform4iv = (type_glUniform4iv)
- context->getProcAddress(QLatin1String("glUniform4ivARB"));
- }
-
- if (funcs->uniform4iv)
- funcs->uniform4iv(location, count, v);
- else
- funcs->uniform4iv = qglfResolveUniform4iv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniformMatrix2fv = (type_glUniformMatrix2fv)
- context->getProcAddress(QLatin1String("glUniformMatrix2fv"));
- if (!funcs->uniformMatrix2fv) {
- funcs->uniformMatrix2fv = (type_glUniformMatrix2fv)
- context->getProcAddress(QLatin1String("glUniformMatrix2fvARB"));
- }
-
- if (funcs->uniformMatrix2fv)
- funcs->uniformMatrix2fv(location, count, transpose, value);
- else
- funcs->uniformMatrix2fv = qglfResolveUniformMatrix2fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniformMatrix3fv = (type_glUniformMatrix3fv)
- context->getProcAddress(QLatin1String("glUniformMatrix3fv"));
- if (!funcs->uniformMatrix3fv) {
- funcs->uniformMatrix3fv = (type_glUniformMatrix3fv)
- context->getProcAddress(QLatin1String("glUniformMatrix3fvARB"));
- }
-
- if (funcs->uniformMatrix3fv)
- funcs->uniformMatrix3fv(location, count, transpose, value);
- else
- funcs->uniformMatrix3fv = qglfResolveUniformMatrix3fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->uniformMatrix4fv = (type_glUniformMatrix4fv)
- context->getProcAddress(QLatin1String("glUniformMatrix4fv"));
- if (!funcs->uniformMatrix4fv) {
- funcs->uniformMatrix4fv = (type_glUniformMatrix4fv)
- context->getProcAddress(QLatin1String("glUniformMatrix4fvARB"));
- }
-
- if (funcs->uniformMatrix4fv)
- funcs->uniformMatrix4fv(location, count, transpose, value);
- else
- funcs->uniformMatrix4fv = qglfResolveUniformMatrix4fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveUseProgram(GLuint program)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glUseProgram)(GLuint program);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->useProgram = (type_glUseProgram)
- context->getProcAddress(QLatin1String("glUseProgram"));
- if (!funcs->useProgram) {
- funcs->useProgram = (type_glUseProgram)
- context->getProcAddress(QLatin1String("glUseProgramObjectARB"));
- }
-
- if (funcs->useProgram)
- funcs->useProgram(program);
- else
- funcs->useProgram = qglfResolveUseProgram;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveValidateProgram(GLuint program)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glValidateProgram)(GLuint program);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->validateProgram = (type_glValidateProgram)
- context->getProcAddress(QLatin1String("glValidateProgram"));
- if (!funcs->validateProgram) {
- funcs->validateProgram = (type_glValidateProgram)
- context->getProcAddress(QLatin1String("glValidateProgramARB"));
- }
-
- if (funcs->validateProgram)
- funcs->validateProgram(program);
- else
- funcs->validateProgram = qglfResolveValidateProgram;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib1f(GLuint indx, GLfloat x)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib1f)(GLuint indx, GLfloat x);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib1f = (type_glVertexAttrib1f)
- context->getProcAddress(QLatin1String("glVertexAttrib1f"));
- if (!funcs->vertexAttrib1f) {
- funcs->vertexAttrib1f = (type_glVertexAttrib1f)
- context->getProcAddress(QLatin1String("glVertexAttrib1fARB"));
- }
-
- if (funcs->vertexAttrib1f)
- funcs->vertexAttrib1f(indx, x);
- else
- funcs->vertexAttrib1f = qglfResolveVertexAttrib1f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib1fv(GLuint indx, const GLfloat* values)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib1fv)(GLuint indx, const GLfloat* values);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib1fv = (type_glVertexAttrib1fv)
- context->getProcAddress(QLatin1String("glVertexAttrib1fv"));
- if (!funcs->vertexAttrib1fv) {
- funcs->vertexAttrib1fv = (type_glVertexAttrib1fv)
- context->getProcAddress(QLatin1String("glVertexAttrib1fvARB"));
- }
-
- if (funcs->vertexAttrib1fv)
- funcs->vertexAttrib1fv(indx, values);
- else
- funcs->vertexAttrib1fv = qglfResolveVertexAttrib1fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib2f = (type_glVertexAttrib2f)
- context->getProcAddress(QLatin1String("glVertexAttrib2f"));
- if (!funcs->vertexAttrib2f) {
- funcs->vertexAttrib2f = (type_glVertexAttrib2f)
- context->getProcAddress(QLatin1String("glVertexAttrib2fARB"));
- }
-
- if (funcs->vertexAttrib2f)
- funcs->vertexAttrib2f(indx, x, y);
- else
- funcs->vertexAttrib2f = qglfResolveVertexAttrib2f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib2fv(GLuint indx, const GLfloat* values)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib2fv)(GLuint indx, const GLfloat* values);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib2fv = (type_glVertexAttrib2fv)
- context->getProcAddress(QLatin1String("glVertexAttrib2fv"));
- if (!funcs->vertexAttrib2fv) {
- funcs->vertexAttrib2fv = (type_glVertexAttrib2fv)
- context->getProcAddress(QLatin1String("glVertexAttrib2fvARB"));
- }
-
- if (funcs->vertexAttrib2fv)
- funcs->vertexAttrib2fv(indx, values);
- else
- funcs->vertexAttrib2fv = qglfResolveVertexAttrib2fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib3f = (type_glVertexAttrib3f)
- context->getProcAddress(QLatin1String("glVertexAttrib3f"));
- if (!funcs->vertexAttrib3f) {
- funcs->vertexAttrib3f = (type_glVertexAttrib3f)
- context->getProcAddress(QLatin1String("glVertexAttrib3fARB"));
- }
-
- if (funcs->vertexAttrib3f)
- funcs->vertexAttrib3f(indx, x, y, z);
- else
- funcs->vertexAttrib3f = qglfResolveVertexAttrib3f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib3fv(GLuint indx, const GLfloat* values)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib3fv)(GLuint indx, const GLfloat* values);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib3fv = (type_glVertexAttrib3fv)
- context->getProcAddress(QLatin1String("glVertexAttrib3fv"));
- if (!funcs->vertexAttrib3fv) {
- funcs->vertexAttrib3fv = (type_glVertexAttrib3fv)
- context->getProcAddress(QLatin1String("glVertexAttrib3fvARB"));
- }
-
- if (funcs->vertexAttrib3fv)
- funcs->vertexAttrib3fv(indx, values);
- else
- funcs->vertexAttrib3fv = qglfResolveVertexAttrib3fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib4f = (type_glVertexAttrib4f)
- context->getProcAddress(QLatin1String("glVertexAttrib4f"));
- if (!funcs->vertexAttrib4f) {
- funcs->vertexAttrib4f = (type_glVertexAttrib4f)
- context->getProcAddress(QLatin1String("glVertexAttrib4fARB"));
- }
-
- if (funcs->vertexAttrib4f)
- funcs->vertexAttrib4f(indx, x, y, z, w);
- else
- funcs->vertexAttrib4f = qglfResolveVertexAttrib4f;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttrib4fv(GLuint indx, const GLfloat* values)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttrib4fv)(GLuint indx, const GLfloat* values);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttrib4fv = (type_glVertexAttrib4fv)
- context->getProcAddress(QLatin1String("glVertexAttrib4fv"));
- if (!funcs->vertexAttrib4fv) {
- funcs->vertexAttrib4fv = (type_glVertexAttrib4fv)
- context->getProcAddress(QLatin1String("glVertexAttrib4fvARB"));
- }
-
- if (funcs->vertexAttrib4fv)
- funcs->vertexAttrib4fv(indx, values);
- else
- funcs->vertexAttrib4fv = qglfResolveVertexAttrib4fv;
-}
-
-static void QT3D_GLF_APIENTRY qglfResolveVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
-{
- typedef void (QT3D_GLF_APIENTRYP type_glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
-
- const QGLContext *context = QGLContext::currentContext();
- QOpenGLFunctionsPrivate *funcs = qt_gl_functions(context);
-
- funcs->vertexAttribPointer = (type_glVertexAttribPointer)
- context->getProcAddress(QLatin1String("glVertexAttribPointer"));
- if (!funcs->vertexAttribPointer) {
- funcs->vertexAttribPointer = (type_glVertexAttribPointer)
- context->getProcAddress(QLatin1String("glVertexAttribPointerARB"));
- }
-
- if (funcs->vertexAttribPointer)
- funcs->vertexAttribPointer(indx, size, type, normalized, stride, ptr);
- else
- funcs->vertexAttribPointer = qglfResolveVertexAttribPointer;
-}
-
-#endif // !QT_OPENGL_ES_2
-
-QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(const QGLContext *)
-{
-#ifndef QT_OPENGL_ES_2
- activeTexture = qglfResolveActiveTexture;
- attachShader = qglfResolveAttachShader;
- bindAttribLocation = qglfResolveBindAttribLocation;
- bindBuffer = qglfResolveBindBuffer;
- bindFramebuffer = qglfResolveBindFramebuffer;
- bindRenderbuffer = qglfResolveBindRenderbuffer;
- blendColor = qglfResolveBlendColor;
- blendEquation = qglfResolveBlendEquation;
- blendEquationSeparate = qglfResolveBlendEquationSeparate;
- blendFuncSeparate = qglfResolveBlendFuncSeparate;
- bufferData = qglfResolveBufferData;
- bufferSubData = qglfResolveBufferSubData;
- checkFramebufferStatus = qglfResolveCheckFramebufferStatus;
- compileShader = qglfResolveCompileShader;
- compressedTexImage2D = qglfResolveCompressedTexImage2D;
- compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D;
- createProgram = qglfResolveCreateProgram;
- createShader = qglfResolveCreateShader;
- deleteBuffers = qglfResolveDeleteBuffers;
- deleteFramebuffers = qglfResolveDeleteFramebuffers;
- deleteProgram = qglfResolveDeleteProgram;
- deleteRenderbuffers = qglfResolveDeleteRenderbuffers;
- deleteShader = qglfResolveDeleteShader;
- detachShader = qglfResolveDetachShader;
- disableVertexAttribArray = qglfResolveDisableVertexAttribArray;
- enableVertexAttribArray = qglfResolveEnableVertexAttribArray;
- framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer;
- framebufferTexture2D = qglfResolveFramebufferTexture2D;
- genBuffers = qglfResolveGenBuffers;
- generateMipmap = qglfResolveGenerateMipmap;
- genFramebuffers = qglfResolveGenFramebuffers;
- genRenderbuffers = qglfResolveGenRenderbuffers;
- getActiveAttrib = qglfResolveGetActiveAttrib;
- getActiveUniform = qglfResolveGetActiveUniform;
- getAttachedShaders = qglfResolveGetAttachedShaders;
- getAttribLocation = qglfResolveGetAttribLocation;
- getBufferParameteriv = qglfResolveGetBufferParameteriv;
- getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv;
- getProgramiv = qglfResolveGetProgramiv;
- getProgramInfoLog = qglfResolveGetProgramInfoLog;
- getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv;
- getShaderiv = qglfResolveGetShaderiv;
- getShaderInfoLog = qglfResolveGetShaderInfoLog;
- getShaderPrecisionFormat = qglfResolveGetShaderPrecisionFormat;
- getShaderSource = qglfResolveGetShaderSource;
- getUniformfv = qglfResolveGetUniformfv;
- getUniformiv = qglfResolveGetUniformiv;
- getUniformLocation = qglfResolveGetUniformLocation;
- getVertexAttribfv = qglfResolveGetVertexAttribfv;
- getVertexAttribiv = qglfResolveGetVertexAttribiv;
- getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv;
- isBuffer = qglfResolveIsBuffer;
- isFramebuffer = qglfResolveIsFramebuffer;
- isProgram = qglfResolveIsProgram;
- isRenderbuffer = qglfResolveIsRenderbuffer;
- isShader = qglfResolveIsShader;
- linkProgram = qglfResolveLinkProgram;
- releaseShaderCompiler = qglfResolveReleaseShaderCompiler;
- renderbufferStorage = qglfResolveRenderbufferStorage;
- sampleCoverage = qglfResolveSampleCoverage;
- shaderBinary = qglfResolveShaderBinary;
- shaderSource = qglfResolveShaderSource;
- stencilFuncSeparate = qglfResolveStencilFuncSeparate;
- stencilMaskSeparate = qglfResolveStencilMaskSeparate;
- stencilOpSeparate = qglfResolveStencilOpSeparate;
- uniform1f = qglfResolveUniform1f;
- uniform1fv = qglfResolveUniform1fv;
- uniform1i = qglfResolveUniform1i;
- uniform1iv = qglfResolveUniform1iv;
- uniform2f = qglfResolveUniform2f;
- uniform2fv = qglfResolveUniform2fv;
- uniform2i = qglfResolveUniform2i;
- uniform2iv = qglfResolveUniform2iv;
- uniform3f = qglfResolveUniform3f;
- uniform3fv = qglfResolveUniform3fv;
- uniform3i = qglfResolveUniform3i;
- uniform3iv = qglfResolveUniform3iv;
- uniform4f = qglfResolveUniform4f;
- uniform4fv = qglfResolveUniform4fv;
- uniform4i = qglfResolveUniform4i;
- uniform4iv = qglfResolveUniform4iv;
- uniformMatrix2fv = qglfResolveUniformMatrix2fv;
- uniformMatrix3fv = qglfResolveUniformMatrix3fv;
- uniformMatrix4fv = qglfResolveUniformMatrix4fv;
- useProgram = qglfResolveUseProgram;
- validateProgram = qglfResolveValidateProgram;
- vertexAttrib1f = qglfResolveVertexAttrib1f;
- vertexAttrib1fv = qglfResolveVertexAttrib1fv;
- vertexAttrib2f = qglfResolveVertexAttrib2f;
- vertexAttrib2fv = qglfResolveVertexAttrib2fv;
- vertexAttrib3f = qglfResolveVertexAttrib3f;
- vertexAttrib3fv = qglfResolveVertexAttrib3fv;
- vertexAttrib4f = qglfResolveVertexAttrib4f;
- vertexAttrib4fv = qglfResolveVertexAttrib4fv;
- vertexAttribPointer = qglfResolveVertexAttribPointer;
-#endif // !QT_OPENGL_ES_2
-}
-
diff --git a/src/threed/api/qopenglfunctions.h b/src/threed/api/qopenglfunctions.h
deleted file mode 100644
index 315846b1..00000000
--- a/src/threed/api/qopenglfunctions.h
+++ /dev/null
@@ -1,2292 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QOPENGLFUNCTIONS_H
-#define QOPENGLFUNCTIONS_H
-
-#include <QtOpenGL/qgl.h>
-#include "qt3dglobal.h"
-#include <QDebug>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-// Types that aren't defined in all system's gl.h files.
-typedef ptrdiff_t qgl_GLintptr;
-typedef ptrdiff_t qgl_GLsizeiptr;
-
-#ifdef Q_WS_WIN
-# define QT3D_GLF_APIENTRY APIENTRY
-#endif
-
-#ifndef Q_WS_MAC
-# ifndef QT3D_GLF_APIENTRYP
-# ifdef QT3D_GLF_APIENTRY
-# define QT3D_GLF_APIENTRYP QT3D_GLF_APIENTRY *
-# else
-# define QT3D_GLF_APIENTRY
-# define QT3D_GLF_APIENTRYP *
-# endif
-# endif
-#else
-# define QT3D_GLF_APIENTRY
-# define QT3D_GLF_APIENTRYP *
-#endif
-
-struct QOpenGLFunctionsPrivate;
-
-// Undefine any macros from GLEW, qglextensions_p.h, etc that
-// may interfere with the definition of QOpenGLFunctions.
-#undef glActiveTexture
-#undef glAttachShader
-#undef glBindAttribLocation
-#undef glBindBuffer
-#undef glBindFramebuffer
-#undef glBindRenderbuffer
-#undef glBlendColor
-#undef glBlendEquation
-#undef glBlendEquationSeparate
-#undef glBlendFuncSeparate
-#undef glBufferData
-#undef glBufferSubData
-#undef glCheckFramebufferStatus
-#undef glClearDepthf
-#undef glCompileShader
-#undef glCompressedTexImage2D
-#undef glCompressedTexSubImage2D
-#undef glCreateProgram
-#undef glCreateShader
-#undef glDeleteBuffers
-#undef glDeleteFramebuffers
-#undef glDeleteProgram
-#undef glDeleteRenderbuffers
-#undef glDeleteShader
-#undef glDepthRangef
-#undef glDetachShader
-#undef glDisableVertexAttribArray
-#undef glEnableVertexAttribArray
-#undef glFramebufferRenderbuffer
-#undef glFramebufferTexture2D
-#undef glGenBuffers
-#undef glGenerateMipmap
-#undef glGenFramebuffers
-#undef glGenRenderbuffers
-#undef glGetActiveAttrib
-#undef glGetActiveUniform
-#undef glGetAttachedShaders
-#undef glGetAttribLocation
-#undef glGetBufferParameteriv
-#undef glGetFramebufferAttachmentParameteriv
-#undef glGetProgramiv
-#undef glGetProgramInfoLog
-#undef glGetRenderbufferParameteriv
-#undef glGetShaderiv
-#undef glGetShaderInfoLog
-#undef glGetShaderPrecisionFormat
-#undef glGetShaderSource
-#undef glGetUniformfv
-#undef glGetUniformiv
-#undef glGetUniformLocation
-#undef glGetVertexAttribfv
-#undef glGetVertexAttribiv
-#undef glGetVertexAttribPointerv
-#undef glIsBuffer
-#undef glIsFramebuffer
-#undef glIsProgram
-#undef glIsRenderbuffer
-#undef glIsShader
-#undef glLinkProgram
-#undef glReleaseShaderCompiler
-#undef glRenderbufferStorage
-#undef glSampleCoverage
-#undef glShaderBinary
-#undef glShaderSource
-#undef glStencilFuncSeparate
-#undef glStencilMaskSeparate
-#undef glStencilOpSeparate
-#undef glUniform1f
-#undef glUniform1fv
-#undef glUniform1i
-#undef glUniform1iv
-#undef glUniform2f
-#undef glUniform2fv
-#undef glUniform2i
-#undef glUniform2iv
-#undef glUniform3f
-#undef glUniform3fv
-#undef glUniform3i
-#undef glUniform3iv
-#undef glUniform4f
-#undef glUniform4fv
-#undef glUniform4i
-#undef glUniform4iv
-#undef glUniformMatrix2fv
-#undef glUniformMatrix3fv
-#undef glUniformMatrix4fv
-#undef glUseProgram
-#undef glValidateProgram
-#undef glVertexAttrib1f
-#undef glVertexAttrib1fv
-#undef glVertexAttrib2f
-#undef glVertexAttrib2fv
-#undef glVertexAttrib3f
-#undef glVertexAttrib3fv
-#undef glVertexAttrib4f
-#undef glVertexAttrib4fv
-#undef glVertexAttribPointer
-
-class Q_QT3D_EXPORT QOpenGLFunctions
-{
-public:
- QOpenGLFunctions();
- explicit QOpenGLFunctions(const QGLContext *context);
- ~QOpenGLFunctions() {}
-
- enum OpenGLFeature
- {
- Multitexture = 0x0001,
- Shaders = 0x0002,
- Buffers = 0x0004,
- Framebuffers = 0x0008,
- BlendColor = 0x0010,
- BlendEquation = 0x0020,
- BlendEquationSeparate = 0x0040,
- BlendFuncSeparate = 0x0080,
- BlendSubtract = 0x0100,
- CompressedTextures = 0x0200,
- Multisample = 0x0400,
- StencilSeparate = 0x0800,
- NPOTTextures = 0x1000
- };
- Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)
-
- QOpenGLFunctions::OpenGLFeatures openGLFeatures() const;
- bool hasOpenGLFeature(QOpenGLFunctions::OpenGLFeature feature) const;
-
- void initializeGLFunctions(const QGLContext *context = 0);
-
- void glActiveTexture(GLenum texture);
- void glAttachShader(GLuint program, GLuint shader);
- void glBindAttribLocation(GLuint program, GLuint index, const char* name);
- void glBindBuffer(GLenum target, GLuint buffer);
- void glBindFramebuffer(GLenum target, GLuint framebuffer);
- void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
- void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
- void glBlendEquation(GLenum mode);
- void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
- void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
- void glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
- void glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
- GLenum glCheckFramebufferStatus(GLenum target);
- void glClearDepthf(GLclampf depth);
- void glCompileShader(GLuint shader);
- void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
- void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
- GLuint glCreateProgram();
- GLuint glCreateShader(GLenum type);
- void glDeleteBuffers(GLsizei n, const GLuint* buffers);
- void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
- void glDeleteProgram(GLuint program);
- void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
- void glDeleteShader(GLuint shader);
- void glDepthRangef(GLclampf zNear, GLclampf zFar);
- void glDetachShader(GLuint program, GLuint shader);
- void glDisableVertexAttribArray(GLuint index);
- void glEnableVertexAttribArray(GLuint index);
- void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
- void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
- void glGenBuffers(GLsizei n, GLuint* buffers);
- void glGenerateMipmap(GLenum target);
- void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
- void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
- void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
- int glGetAttribLocation(GLuint program, const char* name);
- void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
- void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
- void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
- void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
- void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
- void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
- void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
- void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
- void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
- void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
- void glGetUniformiv(GLuint program, GLint location, GLint* params);
- int glGetUniformLocation(GLuint program, const char* name);
- void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
- void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
- void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer);
- GLboolean glIsBuffer(GLuint buffer);
- GLboolean glIsFramebuffer(GLuint framebuffer);
- GLboolean glIsProgram(GLuint program);
- GLboolean glIsRenderbuffer(GLuint renderbuffer);
- GLboolean glIsShader(GLuint shader);
- void glLinkProgram(GLuint program);
- void glReleaseShaderCompiler();
- void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
- void glSampleCoverage(GLclampf value, GLboolean invert);
- void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
- void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length);
- void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
- void glStencilMaskSeparate(GLenum face, GLuint mask);
- void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
- void glUniform1f(GLint location, GLfloat x);
- void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
- void glUniform1i(GLint location, GLint x);
- void glUniform1iv(GLint location, GLsizei count, const GLint* v);
- void glUniform2f(GLint location, GLfloat x, GLfloat y);
- void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
- void glUniform2i(GLint location, GLint x, GLint y);
- void glUniform2iv(GLint location, GLsizei count, const GLint* v);
- void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
- void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
- void glUniform3i(GLint location, GLint x, GLint y, GLint z);
- void glUniform3iv(GLint location, GLsizei count, const GLint* v);
- void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
- void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
- void glUniform4iv(GLint location, GLsizei count, const GLint* v);
- void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void glUseProgram(GLuint program);
- void glValidateProgram(GLuint program);
- void glVertexAttrib1f(GLuint indx, GLfloat x);
- void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
- void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
- void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
- void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
- void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
- void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
- void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
-
-private:
- QOpenGLFunctionsPrivate *d_ptr;
- static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; }
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLFunctions::OpenGLFeatures)
-
-struct QOpenGLFunctionsPrivate
-{
- QOpenGLFunctionsPrivate(const QGLContext *context = 0);
-
-#ifndef QT_OPENGL_ES_2
- void (QT3D_GLF_APIENTRYP activeTexture)(GLenum texture);
- void (QT3D_GLF_APIENTRYP attachShader)(GLuint program, GLuint shader);
- void (QT3D_GLF_APIENTRYP bindAttribLocation)(GLuint program, GLuint index, const char* name);
- void (QT3D_GLF_APIENTRYP bindBuffer)(GLenum target, GLuint buffer);
- void (QT3D_GLF_APIENTRYP bindFramebuffer)(GLenum target, GLuint framebuffer);
- void (QT3D_GLF_APIENTRYP bindRenderbuffer)(GLenum target, GLuint renderbuffer);
- void (QT3D_GLF_APIENTRYP blendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
- void (QT3D_GLF_APIENTRYP blendEquation)(GLenum mode);
- void (QT3D_GLF_APIENTRYP blendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
- void (QT3D_GLF_APIENTRYP blendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
- void (QT3D_GLF_APIENTRYP bufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
- void (QT3D_GLF_APIENTRYP bufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
- GLenum (QT3D_GLF_APIENTRYP checkFramebufferStatus)(GLenum target);
- void (QT3D_GLF_APIENTRYP compileShader)(GLuint shader);
- void (QT3D_GLF_APIENTRYP compressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
- void (QT3D_GLF_APIENTRYP compressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
- GLuint (QT3D_GLF_APIENTRYP createProgram)();
- GLuint (QT3D_GLF_APIENTRYP createShader)(GLenum type);
- void (QT3D_GLF_APIENTRYP deleteBuffers)(GLsizei n, const GLuint* buffers);
- void (QT3D_GLF_APIENTRYP deleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
- void (QT3D_GLF_APIENTRYP deleteProgram)(GLuint program);
- void (QT3D_GLF_APIENTRYP deleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
- void (QT3D_GLF_APIENTRYP deleteShader)(GLuint shader);
- void (QT3D_GLF_APIENTRYP detachShader)(GLuint program, GLuint shader);
- void (QT3D_GLF_APIENTRYP disableVertexAttribArray)(GLuint index);
- void (QT3D_GLF_APIENTRYP enableVertexAttribArray)(GLuint index);
- void (QT3D_GLF_APIENTRYP framebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
- void (QT3D_GLF_APIENTRYP framebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
- void (QT3D_GLF_APIENTRYP genBuffers)(GLsizei n, GLuint* buffers);
- void (QT3D_GLF_APIENTRYP generateMipmap)(GLenum target);
- void (QT3D_GLF_APIENTRYP genFramebuffers)(GLsizei n, GLuint* framebuffers);
- void (QT3D_GLF_APIENTRYP genRenderbuffers)(GLsizei n, GLuint* renderbuffers);
- void (QT3D_GLF_APIENTRYP getActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- void (QT3D_GLF_APIENTRYP getActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
- void (QT3D_GLF_APIENTRYP getAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
- int (QT3D_GLF_APIENTRYP getAttribLocation)(GLuint program, const char* name);
- void (QT3D_GLF_APIENTRYP getBufferParameteriv)(GLenum target, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getProgramiv)(GLuint program, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
- void (QT3D_GLF_APIENTRYP getRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getShaderiv)(GLuint shader, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
- void (QT3D_GLF_APIENTRYP getShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
- void (QT3D_GLF_APIENTRYP getShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
- void (QT3D_GLF_APIENTRYP getUniformfv)(GLuint program, GLint location, GLfloat* params);
- void (QT3D_GLF_APIENTRYP getUniformiv)(GLuint program, GLint location, GLint* params);
- int (QT3D_GLF_APIENTRYP getUniformLocation)(GLuint program, const char* name);
- void (QT3D_GLF_APIENTRYP getVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
- void (QT3D_GLF_APIENTRYP getVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
- void (QT3D_GLF_APIENTRYP getVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer);
- GLboolean (QT3D_GLF_APIENTRYP isBuffer)(GLuint buffer);
- GLboolean (QT3D_GLF_APIENTRYP isFramebuffer)(GLuint framebuffer);
- GLboolean (QT3D_GLF_APIENTRYP isProgram)(GLuint program);
- GLboolean (QT3D_GLF_APIENTRYP isRenderbuffer)(GLuint renderbuffer);
- GLboolean (QT3D_GLF_APIENTRYP isShader)(GLuint shader);
- void (QT3D_GLF_APIENTRYP linkProgram)(GLuint program);
- void (QT3D_GLF_APIENTRYP releaseShaderCompiler)();
- void (QT3D_GLF_APIENTRYP renderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
- void (QT3D_GLF_APIENTRYP sampleCoverage)(GLclampf value, GLboolean invert);
- void (QT3D_GLF_APIENTRYP shaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
- void (QT3D_GLF_APIENTRYP shaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length);
- void (QT3D_GLF_APIENTRYP stencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
- void (QT3D_GLF_APIENTRYP stencilMaskSeparate)(GLenum face, GLuint mask);
- void (QT3D_GLF_APIENTRYP stencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
- void (QT3D_GLF_APIENTRYP uniform1f)(GLint location, GLfloat x);
- void (QT3D_GLF_APIENTRYP uniform1fv)(GLint location, GLsizei count, const GLfloat* v);
- void (QT3D_GLF_APIENTRYP uniform1i)(GLint location, GLint x);
- void (QT3D_GLF_APIENTRYP uniform1iv)(GLint location, GLsizei count, const GLint* v);
- void (QT3D_GLF_APIENTRYP uniform2f)(GLint location, GLfloat x, GLfloat y);
- void (QT3D_GLF_APIENTRYP uniform2fv)(GLint location, GLsizei count, const GLfloat* v);
- void (QT3D_GLF_APIENTRYP uniform2i)(GLint location, GLint x, GLint y);
- void (QT3D_GLF_APIENTRYP uniform2iv)(GLint location, GLsizei count, const GLint* v);
- void (QT3D_GLF_APIENTRYP uniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
- void (QT3D_GLF_APIENTRYP uniform3fv)(GLint location, GLsizei count, const GLfloat* v);
- void (QT3D_GLF_APIENTRYP uniform3i)(GLint location, GLint x, GLint y, GLint z);
- void (QT3D_GLF_APIENTRYP uniform3iv)(GLint location, GLsizei count, const GLint* v);
- void (QT3D_GLF_APIENTRYP uniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- void (QT3D_GLF_APIENTRYP uniform4fv)(GLint location, GLsizei count, const GLfloat* v);
- void (QT3D_GLF_APIENTRYP uniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
- void (QT3D_GLF_APIENTRYP uniform4iv)(GLint location, GLsizei count, const GLint* v);
- void (QT3D_GLF_APIENTRYP uniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void (QT3D_GLF_APIENTRYP uniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void (QT3D_GLF_APIENTRYP uniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
- void (QT3D_GLF_APIENTRYP useProgram)(GLuint program);
- void (QT3D_GLF_APIENTRYP validateProgram)(GLuint program);
- void (QT3D_GLF_APIENTRYP vertexAttrib1f)(GLuint indx, GLfloat x);
- void (QT3D_GLF_APIENTRYP vertexAttrib1fv)(GLuint indx, const GLfloat* values);
- void (QT3D_GLF_APIENTRYP vertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
- void (QT3D_GLF_APIENTRYP vertexAttrib2fv)(GLuint indx, const GLfloat* values);
- void (QT3D_GLF_APIENTRYP vertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
- void (QT3D_GLF_APIENTRYP vertexAttrib3fv)(GLuint indx, const GLfloat* values);
- void (QT3D_GLF_APIENTRYP vertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- void (QT3D_GLF_APIENTRYP vertexAttrib4fv)(GLuint indx, const GLfloat* values);
- void (QT3D_GLF_APIENTRYP vertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
-#endif
-};
-
-inline void QOpenGLFunctions::glActiveTexture(GLenum texture)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glActiveTexture(texture);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->activeTexture(texture);
-#endif
-}
-
-inline void QOpenGLFunctions::glAttachShader(GLuint program, GLuint shader)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glAttachShader(program, shader);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->attachShader(program, shader);
-#endif
-}
-
-inline void QOpenGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBindAttribLocation(program, index, name);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bindAttribLocation(program, index, name);
-#endif
-}
-
-inline void QOpenGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBindBuffer(target, buffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bindBuffer(target, buffer);
-#endif
-}
-
-inline void QOpenGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBindFramebuffer(target, framebuffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bindFramebuffer(target, framebuffer);
-#endif
-}
-
-inline void QOpenGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBindRenderbuffer(target, renderbuffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bindRenderbuffer(target, renderbuffer);
-#endif
-}
-
-inline void QOpenGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBlendColor(red, green, blue, alpha);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->blendColor(red, green, blue, alpha);
-#endif
-}
-
-inline void QOpenGLFunctions::glBlendEquation(GLenum mode)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBlendEquation(mode);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->blendEquation(mode);
-#endif
-}
-
-inline void QOpenGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBlendEquationSeparate(modeRGB, modeAlpha);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->blendEquationSeparate(modeRGB, modeAlpha);
-#endif
-}
-
-inline void QOpenGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-#endif
-}
-
-inline void QOpenGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBufferData(target, size, data, usage);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bufferData(target, size, data, usage);
-#endif
-}
-
-inline void QOpenGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glBufferSubData(target, offset, size, data);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->bufferSubData(target, offset, size, data);
-#endif
-}
-
-inline GLenum QOpenGLFunctions::glCheckFramebufferStatus(GLenum target)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glCheckFramebufferStatus(target);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->checkFramebufferStatus(target);
-#endif
-}
-
-inline void QOpenGLFunctions::glClearDepthf(GLclampf depth)
-{
-#ifndef QT_OPENGL_ES
- ::glClearDepth(depth);
-#else
- ::glClearDepthf(depth);
-#endif
-}
-
-inline void QOpenGLFunctions::glCompileShader(GLuint shader)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glCompileShader(shader);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->compileShader(shader);
-#endif
-}
-
-inline void QOpenGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
-#endif
-}
-
-inline void QOpenGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
-#endif
-}
-
-inline GLuint QOpenGLFunctions::glCreateProgram()
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glCreateProgram();
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->createProgram();
-#endif
-}
-
-inline GLuint QOpenGLFunctions::glCreateShader(GLenum type)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glCreateShader(type);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->createShader(type);
-#endif
-}
-
-inline void QOpenGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDeleteBuffers(n, buffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->deleteBuffers(n, buffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDeleteFramebuffers(n, framebuffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->deleteFramebuffers(n, framebuffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glDeleteProgram(GLuint program)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDeleteProgram(program);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->deleteProgram(program);
-#endif
-}
-
-inline void QOpenGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDeleteRenderbuffers(n, renderbuffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->deleteRenderbuffers(n, renderbuffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glDeleteShader(GLuint shader)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDeleteShader(shader);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->deleteShader(shader);
-#endif
-}
-
-inline void QOpenGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
-{
-#ifndef QT_OPENGL_ES
- ::glDepthRange(zNear, zFar);
-#else
- ::glDepthRangef(zNear, zFar);
-#endif
-}
-
-inline void QOpenGLFunctions::glDetachShader(GLuint program, GLuint shader)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDetachShader(program, shader);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->detachShader(program, shader);
-#endif
-}
-
-inline void QOpenGLFunctions::glDisableVertexAttribArray(GLuint index)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glDisableVertexAttribArray(index);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->disableVertexAttribArray(index);
-#endif
-}
-
-inline void QOpenGLFunctions::glEnableVertexAttribArray(GLuint index)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glEnableVertexAttribArray(index);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->enableVertexAttribArray(index);
-#endif
-}
-
-inline void QOpenGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
-#endif
-}
-
-inline void QOpenGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glFramebufferTexture2D(target, attachment, textarget, texture, level);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->framebufferTexture2D(target, attachment, textarget, texture, level);
-#endif
-}
-
-inline void QOpenGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGenBuffers(n, buffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->genBuffers(n, buffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glGenerateMipmap(GLenum target)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGenerateMipmap(target);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->generateMipmap(target);
-#endif
-}
-
-inline void QOpenGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGenFramebuffers(n, framebuffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->genFramebuffers(n, framebuffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGenRenderbuffers(n, renderbuffers);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->genRenderbuffers(n, renderbuffers);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetActiveAttrib(program, index, bufsize, length, size, type, name);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getActiveAttrib(program, index, bufsize, length, size, type, name);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetActiveUniform(program, index, bufsize, length, size, type, name);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getActiveUniform(program, index, bufsize, length, size, type, name);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetAttachedShaders(program, maxcount, count, shaders);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getAttachedShaders(program, maxcount, count, shaders);
-#endif
-}
-
-inline int QOpenGLFunctions::glGetAttribLocation(GLuint program, const char* name)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glGetAttribLocation(program, name);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->getAttribLocation(program, name);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetBufferParameteriv(target, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getBufferParameteriv(target, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetProgramiv(program, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getProgramiv(program, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetProgramInfoLog(program, bufsize, length, infolog);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getProgramInfoLog(program, bufsize, length, infolog);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetRenderbufferParameteriv(target, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getRenderbufferParameteriv(target, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetShaderiv(shader, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getShaderiv(shader, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetShaderInfoLog(shader, bufsize, length, infolog);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getShaderInfoLog(shader, bufsize, length, infolog);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetShaderSource(shader, bufsize, length, source);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getShaderSource(shader, bufsize, length, source);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetUniformfv(program, location, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getUniformfv(program, location, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetUniformiv(program, location, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getUniformiv(program, location, params);
-#endif
-}
-
-inline int QOpenGLFunctions::glGetUniformLocation(GLuint program, const char* name)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glGetUniformLocation(program, name);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->getUniformLocation(program, name);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetVertexAttribfv(index, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getVertexAttribfv(index, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetVertexAttribiv(index, pname, params);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getVertexAttribiv(index, pname, params);
-#endif
-}
-
-inline void QOpenGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glGetVertexAttribPointerv(index, pname, pointer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->getVertexAttribPointerv(index, pname, pointer);
-#endif
-}
-
-inline GLboolean QOpenGLFunctions::glIsBuffer(GLuint buffer)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glIsBuffer(buffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->isBuffer(buffer);
-#endif
-}
-
-inline GLboolean QOpenGLFunctions::glIsFramebuffer(GLuint framebuffer)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glIsFramebuffer(framebuffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->isFramebuffer(framebuffer);
-#endif
-}
-
-inline GLboolean QOpenGLFunctions::glIsProgram(GLuint program)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glIsProgram(program);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->isProgram(program);
-#endif
-}
-
-inline GLboolean QOpenGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glIsRenderbuffer(renderbuffer);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->isRenderbuffer(renderbuffer);
-#endif
-}
-
-inline GLboolean QOpenGLFunctions::glIsShader(GLuint shader)
-{
-#if defined(QT_OPENGL_ES_2)
- return ::glIsShader(shader);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- return d_ptr->isShader(shader);
-#endif
-}
-
-inline void QOpenGLFunctions::glLinkProgram(GLuint program)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glLinkProgram(program);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->linkProgram(program);
-#endif
-}
-
-inline void QOpenGLFunctions::glReleaseShaderCompiler()
-{
-#if defined(QT_OPENGL_ES_2)
- ::glReleaseShaderCompiler();
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->releaseShaderCompiler();
-#endif
-}
-
-inline void QOpenGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glRenderbufferStorage(target, internalformat, width, height);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->renderbufferStorage(target, internalformat, width, height);
-#endif
-}
-
-inline void QOpenGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glSampleCoverage(value, invert);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->sampleCoverage(value, invert);
-#endif
-}
-
-inline void QOpenGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glShaderBinary(n, shaders, binaryformat, binary, length);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->shaderBinary(n, shaders, binaryformat, binary, length);
-#endif
-}
-
-inline void QOpenGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glShaderSource(shader, count, string, length);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->shaderSource(shader, count, string, length);
-#endif
-}
-
-inline void QOpenGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glStencilFuncSeparate(face, func, ref, mask);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->stencilFuncSeparate(face, func, ref, mask);
-#endif
-}
-
-inline void QOpenGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glStencilMaskSeparate(face, mask);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->stencilMaskSeparate(face, mask);
-#endif
-}
-
-inline void QOpenGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glStencilOpSeparate(face, fail, zfail, zpass);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->stencilOpSeparate(face, fail, zfail, zpass);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform1f(GLint location, GLfloat x)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform1f(location, x);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform1f(location, x);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform1fv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform1fv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform1i(GLint location, GLint x)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform1i(location, x);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform1i(location, x);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform1iv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform1iv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform2f(location, x, y);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform2f(location, x, y);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform2fv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform2fv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform2i(location, x, y);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform2i(location, x, y);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform2iv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform2iv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform3f(location, x, y, z);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform3f(location, x, y, z);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform3fv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform3fv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform3i(location, x, y, z);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform3i(location, x, y, z);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform3iv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform3iv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform4f(location, x, y, z, w);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform4f(location, x, y, z, w);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform4fv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform4fv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform4i(location, x, y, z, w);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform4i(location, x, y, z, w);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniform4iv(location, count, v);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniform4iv(location, count, v);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniformMatrix2fv(location, count, transpose, value);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniformMatrix2fv(location, count, transpose, value);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniformMatrix3fv(location, count, transpose, value);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniformMatrix3fv(location, count, transpose, value);
-#endif
-}
-
-inline void QOpenGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUniformMatrix4fv(location, count, transpose, value);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->uniformMatrix4fv(location, count, transpose, value);
-#endif
-}
-
-inline void QOpenGLFunctions::glUseProgram(GLuint program)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glUseProgram(program);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->useProgram(program);
-#endif
-}
-
-inline void QOpenGLFunctions::glValidateProgram(GLuint program)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glValidateProgram(program);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->validateProgram(program);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib1f(indx, x);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib1f(indx, x);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib1fv(indx, values);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib1fv(indx, values);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib2f(indx, x, y);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib2f(indx, x, y);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib2fv(indx, values);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib2fv(indx, values);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib3f(indx, x, y, z);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib3f(indx, x, y, z);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib3fv(indx, values);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib3fv(indx, values);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib4f(indx, x, y, z, w);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib4f(indx, x, y, z, w);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttrib4fv(indx, values);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttrib4fv(indx, values);
-#endif
-}
-
-inline void QOpenGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
-{
-#if defined(QT_OPENGL_ES_2)
- ::glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
-#else
- Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
- d_ptr->vertexAttribPointer(indx, size, type, normalized, stride, ptr);
-#endif
-}
-
-#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#endif
-#ifndef GL_ACTIVE_ATTRIBUTES
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#endif
-#ifndef GL_ACTIVE_TEXTURE
-#define GL_ACTIVE_TEXTURE 0x84E0
-#endif
-#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#endif
-#ifndef GL_ACTIVE_UNIFORMS
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#endif
-#ifndef GL_ALIASED_LINE_WIDTH_RANGE
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#endif
-#ifndef GL_ALIASED_POINT_SIZE_RANGE
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#endif
-#ifndef GL_ALPHA
-#define GL_ALPHA 0x1906
-#endif
-#ifndef GL_ALPHA_BITS
-#define GL_ALPHA_BITS 0x0D55
-#endif
-#ifndef GL_ALWAYS
-#define GL_ALWAYS 0x0207
-#endif
-#ifndef GL_ARRAY_BUFFER
-#define GL_ARRAY_BUFFER 0x8892
-#endif
-#ifndef GL_ARRAY_BUFFER_BINDING
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#endif
-#ifndef GL_ATTACHED_SHADERS
-#define GL_ATTACHED_SHADERS 0x8B85
-#endif
-#ifndef GL_BACK
-#define GL_BACK 0x0405
-#endif
-#ifndef GL_BLEND
-#define GL_BLEND 0x0BE2
-#endif
-#ifndef GL_BLEND_COLOR
-#define GL_BLEND_COLOR 0x8005
-#endif
-#ifndef GL_BLEND_DST_ALPHA
-#define GL_BLEND_DST_ALPHA 0x80CA
-#endif
-#ifndef GL_BLEND_DST_RGB
-#define GL_BLEND_DST_RGB 0x80C8
-#endif
-#ifndef GL_BLEND_EQUATION
-#define GL_BLEND_EQUATION 0x8009
-#endif
-#ifndef GL_BLEND_EQUATION_ALPHA
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#endif
-#ifndef GL_BLEND_EQUATION_RGB
-#define GL_BLEND_EQUATION_RGB 0x8009
-#endif
-#ifndef GL_BLEND_SRC_ALPHA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#endif
-#ifndef GL_BLEND_SRC_RGB
-#define GL_BLEND_SRC_RGB 0x80C9
-#endif
-#ifndef GL_BLUE_BITS
-#define GL_BLUE_BITS 0x0D54
-#endif
-#ifndef GL_BOOL
-#define GL_BOOL 0x8B56
-#endif
-#ifndef GL_BOOL_VEC2
-#define GL_BOOL_VEC2 0x8B57
-#endif
-#ifndef GL_BOOL_VEC3
-#define GL_BOOL_VEC3 0x8B58
-#endif
-#ifndef GL_BOOL_VEC4
-#define GL_BOOL_VEC4 0x8B59
-#endif
-#ifndef GL_BUFFER_SIZE
-#define GL_BUFFER_SIZE 0x8764
-#endif
-#ifndef GL_BUFFER_USAGE
-#define GL_BUFFER_USAGE 0x8765
-#endif
-#ifndef GL_BYTE
-#define GL_BYTE 0x1400
-#endif
-#ifndef GL_CCW
-#define GL_CCW 0x0901
-#endif
-#ifndef GL_CLAMP_TO_EDGE
-#define GL_CLAMP_TO_EDGE 0x812F
-#endif
-#ifndef GL_COLOR_ATTACHMENT0
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#endif
-#ifndef GL_COLOR_BUFFER_BIT
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#endif
-#ifndef GL_COLOR_CLEAR_VALUE
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#endif
-#ifndef GL_COLOR_WRITEMASK
-#define GL_COLOR_WRITEMASK 0x0C23
-#endif
-#ifndef GL_COMPILE_STATUS
-#define GL_COMPILE_STATUS 0x8B81
-#endif
-#ifndef GL_COMPRESSED_TEXTURE_FORMATS
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#endif
-#ifndef GL_CONSTANT_ALPHA
-#define GL_CONSTANT_ALPHA 0x8003
-#endif
-#ifndef GL_CONSTANT_COLOR
-#define GL_CONSTANT_COLOR 0x8001
-#endif
-#ifndef GL_CULL_FACE
-#define GL_CULL_FACE 0x0B44
-#endif
-#ifndef GL_CULL_FACE_MODE
-#define GL_CULL_FACE_MODE 0x0B45
-#endif
-#ifndef GL_CURRENT_PROGRAM
-#define GL_CURRENT_PROGRAM 0x8B8D
-#endif
-#ifndef GL_CURRENT_VERTEX_ATTRIB
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#endif
-#ifndef GL_CW
-#define GL_CW 0x0900
-#endif
-#ifndef GL_DECR
-#define GL_DECR 0x1E03
-#endif
-#ifndef GL_DECR_WRAP
-#define GL_DECR_WRAP 0x8508
-#endif
-#ifndef GL_DELETE_STATUS
-#define GL_DELETE_STATUS 0x8B80
-#endif
-#ifndef GL_DEPTH_ATTACHMENT
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#endif
-#ifndef GL_DEPTH_BITS
-#define GL_DEPTH_BITS 0x0D56
-#endif
-#ifndef GL_DEPTH_BUFFER_BIT
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#endif
-#ifndef GL_DEPTH_CLEAR_VALUE
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#endif
-#ifndef GL_DEPTH_COMPONENT
-#define GL_DEPTH_COMPONENT 0x1902
-#endif
-#ifndef GL_DEPTH_COMPONENT16
-#define GL_DEPTH_COMPONENT16 0x81A5
-#endif
-#ifndef GL_DEPTH_FUNC
-#define GL_DEPTH_FUNC 0x0B74
-#endif
-#ifndef GL_DEPTH_RANGE
-#define GL_DEPTH_RANGE 0x0B70
-#endif
-#ifndef GL_DEPTH_TEST
-#define GL_DEPTH_TEST 0x0B71
-#endif
-#ifndef GL_DEPTH_WRITEMASK
-#define GL_DEPTH_WRITEMASK 0x0B72
-#endif
-#ifndef GL_DITHER
-#define GL_DITHER 0x0BD0
-#endif
-#ifndef GL_DONT_CARE
-#define GL_DONT_CARE 0x1100
-#endif
-#ifndef GL_DST_ALPHA
-#define GL_DST_ALPHA 0x0304
-#endif
-#ifndef GL_DST_COLOR
-#define GL_DST_COLOR 0x0306
-#endif
-#ifndef GL_DYNAMIC_DRAW
-#define GL_DYNAMIC_DRAW 0x88E8
-#endif
-#ifndef GL_ELEMENT_ARRAY_BUFFER
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#endif
-#ifndef GL_ELEMENT_ARRAY_BUFFER_BINDING
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#endif
-#ifndef GL_EQUAL
-#define GL_EQUAL 0x0202
-#endif
-#ifndef GL_EXTENSIONS
-#define GL_EXTENSIONS 0x1F03
-#endif
-#ifndef GL_FALSE
-#define GL_FALSE 0
-#endif
-#ifndef GL_FASTEST
-#define GL_FASTEST 0x1101
-#endif
-#ifndef GL_FIXED
-#define GL_FIXED 0x140C
-#endif
-#ifndef GL_FLOAT
-#define GL_FLOAT 0x1406
-#endif
-#ifndef GL_FLOAT_MAT2
-#define GL_FLOAT_MAT2 0x8B5A
-#endif
-#ifndef GL_FLOAT_MAT3
-#define GL_FLOAT_MAT3 0x8B5B
-#endif
-#ifndef GL_FLOAT_MAT4
-#define GL_FLOAT_MAT4 0x8B5C
-#endif
-#ifndef GL_FLOAT_VEC2
-#define GL_FLOAT_VEC2 0x8B50
-#endif
-#ifndef GL_FLOAT_VEC3
-#define GL_FLOAT_VEC3 0x8B51
-#endif
-#ifndef GL_FLOAT_VEC4
-#define GL_FLOAT_VEC4 0x8B52
-#endif
-#ifndef GL_FRAGMENT_SHADER
-#define GL_FRAGMENT_SHADER 0x8B30
-#endif
-#ifndef GL_FRAMEBUFFER
-#define GL_FRAMEBUFFER 0x8D40
-#endif
-#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#endif
-#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#endif
-#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#endif
-#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#endif
-#ifndef GL_FRAMEBUFFER_BINDING
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#endif
-#ifndef GL_FRAMEBUFFER_COMPLETE
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#endif
-#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#endif
-#ifndef GL_FRAMEBUFFER_UNSUPPORTED
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#endif
-#ifndef GL_FRONT
-#define GL_FRONT 0x0404
-#endif
-#ifndef GL_FRONT_AND_BACK
-#define GL_FRONT_AND_BACK 0x0408
-#endif
-#ifndef GL_FRONT_FACE
-#define GL_FRONT_FACE 0x0B46
-#endif
-#ifndef GL_FUNC_ADD
-#define GL_FUNC_ADD 0x8006
-#endif
-#ifndef GL_FUNC_REVERSE_SUBTRACT
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#endif
-#ifndef GL_FUNC_SUBTRACT
-#define GL_FUNC_SUBTRACT 0x800A
-#endif
-#ifndef GL_GENERATE_MIPMAP_HINT
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-#endif
-#ifndef GL_GEQUAL
-#define GL_GEQUAL 0x0206
-#endif
-#ifndef GL_GREATER
-#define GL_GREATER 0x0204
-#endif
-#ifndef GL_GREEN_BITS
-#define GL_GREEN_BITS 0x0D53
-#endif
-#ifndef GL_HIGH_FLOAT
-#define GL_HIGH_FLOAT 0x8DF2
-#endif
-#ifndef GL_HIGH_INT
-#define GL_HIGH_INT 0x8DF5
-#endif
-#ifndef GL_IMPLEMENTATION_COLOR_READ_FORMAT
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-#endif
-#ifndef GL_IMPLEMENTATION_COLOR_READ_TYPE
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#endif
-#ifndef GL_INCR
-#define GL_INCR 0x1E02
-#endif
-#ifndef GL_INCR_WRAP
-#define GL_INCR_WRAP 0x8507
-#endif
-#ifndef GL_INFO_LOG_LENGTH
-#define GL_INFO_LOG_LENGTH 0x8B84
-#endif
-#ifndef GL_INT
-#define GL_INT 0x1404
-#endif
-#ifndef GL_INT_VEC2
-#define GL_INT_VEC2 0x8B53
-#endif
-#ifndef GL_INT_VEC3
-#define GL_INT_VEC3 0x8B54
-#endif
-#ifndef GL_INT_VEC4
-#define GL_INT_VEC4 0x8B55
-#endif
-#ifndef GL_INVALID_ENUM
-#define GL_INVALID_ENUM 0x0500
-#endif
-#ifndef GL_INVALID_FRAMEBUFFER_OPERATION
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#endif
-#ifndef GL_INVALID_OPERATION
-#define GL_INVALID_OPERATION 0x0502
-#endif
-#ifndef GL_INVALID_VALUE
-#define GL_INVALID_VALUE 0x0501
-#endif
-#ifndef GL_INVERT
-#define GL_INVERT 0x150A
-#endif
-#ifndef GL_KEEP
-#define GL_KEEP 0x1E00
-#endif
-#ifndef GL_LEQUAL
-#define GL_LEQUAL 0x0203
-#endif
-#ifndef GL_LESS
-#define GL_LESS 0x0201
-#endif
-#ifndef GL_LINEAR
-#define GL_LINEAR 0x2601
-#endif
-#ifndef GL_LINEAR_MIPMAP_LINEAR
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#endif
-#ifndef GL_LINEAR_MIPMAP_NEAREST
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#endif
-#ifndef GL_LINE_LOOP
-#define GL_LINE_LOOP 0x0002
-#endif
-#ifndef GL_LINES
-#define GL_LINES 0x0001
-#endif
-#ifndef GL_LINE_STRIP
-#define GL_LINE_STRIP 0x0003
-#endif
-#ifndef GL_LINE_WIDTH
-#define GL_LINE_WIDTH 0x0B21
-#endif
-#ifndef GL_LINK_STATUS
-#define GL_LINK_STATUS 0x8B82
-#endif
-#ifndef GL_LOW_FLOAT
-#define GL_LOW_FLOAT 0x8DF0
-#endif
-#ifndef GL_LOW_INT
-#define GL_LOW_INT 0x8DF3
-#endif
-#ifndef GL_LUMINANCE
-#define GL_LUMINANCE 0x1909
-#endif
-#ifndef GL_LUMINANCE_ALPHA
-#define GL_LUMINANCE_ALPHA 0x190A
-#endif
-#ifndef GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#endif
-#ifndef GL_MAX_CUBE_MAP_TEXTURE_SIZE
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#endif
-#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#endif
-#ifndef GL_MAX_RENDERBUFFER_SIZE
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#endif
-#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#endif
-#ifndef GL_MAX_TEXTURE_SIZE
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#endif
-#ifndef GL_MAX_VARYING_VECTORS
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#endif
-#ifndef GL_MAX_VERTEX_ATTRIBS
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#endif
-#ifndef GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#endif
-#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#endif
-#ifndef GL_MAX_VIEWPORT_DIMS
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#endif
-#ifndef GL_MEDIUM_FLOAT
-#define GL_MEDIUM_FLOAT 0x8DF1
-#endif
-#ifndef GL_MEDIUM_INT
-#define GL_MEDIUM_INT 0x8DF4
-#endif
-#ifndef GL_MIRRORED_REPEAT
-#define GL_MIRRORED_REPEAT 0x8370
-#endif
-#ifndef GL_NEAREST
-#define GL_NEAREST 0x2600
-#endif
-#ifndef GL_NEAREST_MIPMAP_LINEAR
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#endif
-#ifndef GL_NEAREST_MIPMAP_NEAREST
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#endif
-#ifndef GL_NEVER
-#define GL_NEVER 0x0200
-#endif
-#ifndef GL_NICEST
-#define GL_NICEST 0x1102
-#endif
-#ifndef GL_NO_ERROR
-#define GL_NO_ERROR 0
-#endif
-#ifndef GL_NONE
-#define GL_NONE 0
-#endif
-#ifndef GL_NOTEQUAL
-#define GL_NOTEQUAL 0x0205
-#endif
-#ifndef GL_NUM_COMPRESSED_TEXTURE_FORMATS
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#endif
-#ifndef GL_NUM_SHADER_BINARY_FORMATS
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-#endif
-#ifndef GL_ONE
-#define GL_ONE 1
-#endif
-#ifndef GL_ONE_MINUS_CONSTANT_ALPHA
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#endif
-#ifndef GL_ONE_MINUS_CONSTANT_COLOR
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#endif
-#ifndef GL_ONE_MINUS_DST_ALPHA
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#endif
-#ifndef GL_ONE_MINUS_DST_COLOR
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#endif
-#ifndef GL_ONE_MINUS_SRC_ALPHA
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#endif
-#ifndef GL_ONE_MINUS_SRC_COLOR
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#endif
-#ifndef GL_OUT_OF_MEMORY
-#define GL_OUT_OF_MEMORY 0x0505
-#endif
-#ifndef GL_PACK_ALIGNMENT
-#define GL_PACK_ALIGNMENT 0x0D05
-#endif
-#ifndef GL_POINTS
-#define GL_POINTS 0x0000
-#endif
-#ifndef GL_POLYGON_OFFSET_FACTOR
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#endif
-#ifndef GL_POLYGON_OFFSET_FILL
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#endif
-#ifndef GL_POLYGON_OFFSET_UNITS
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#endif
-#ifndef GL_RED_BITS
-#define GL_RED_BITS 0x0D52
-#endif
-#ifndef GL_RENDERBUFFER
-#define GL_RENDERBUFFER 0x8D41
-#endif
-#ifndef GL_RENDERBUFFER_ALPHA_SIZE
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#endif
-#ifndef GL_RENDERBUFFER_BINDING
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#endif
-#ifndef GL_RENDERBUFFER_BLUE_SIZE
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#endif
-#ifndef GL_RENDERBUFFER_DEPTH_SIZE
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#endif
-#ifndef GL_RENDERBUFFER_GREEN_SIZE
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#endif
-#ifndef GL_RENDERBUFFER_HEIGHT
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#endif
-#ifndef GL_RENDERBUFFER_INTERNAL_FORMAT
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#endif
-#ifndef GL_RENDERBUFFER_RED_SIZE
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#endif
-#ifndef GL_RENDERBUFFER_STENCIL_SIZE
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#endif
-#ifndef GL_RENDERBUFFER_WIDTH
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#endif
-#ifndef GL_RENDERER
-#define GL_RENDERER 0x1F01
-#endif
-#ifndef GL_REPEAT
-#define GL_REPEAT 0x2901
-#endif
-#ifndef GL_REPLACE
-#define GL_REPLACE 0x1E01
-#endif
-#ifndef GL_RGB
-#define GL_RGB 0x1907
-#endif
-#ifndef GL_RGB565
-#define GL_RGB565 0x8D62
-#endif
-#ifndef GL_RGB5_A1
-#define GL_RGB5_A1 0x8057
-#endif
-#ifndef GL_RGBA
-#define GL_RGBA 0x1908
-#endif
-#ifndef GL_RGBA4
-#define GL_RGBA4 0x8056
-#endif
-#ifndef GL_SAMPLE_ALPHA_TO_COVERAGE
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#endif
-#ifndef GL_SAMPLE_BUFFERS
-#define GL_SAMPLE_BUFFERS 0x80A8
-#endif
-#ifndef GL_SAMPLE_COVERAGE
-#define GL_SAMPLE_COVERAGE 0x80A0
-#endif
-#ifndef GL_SAMPLE_COVERAGE_INVERT
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#endif
-#ifndef GL_SAMPLE_COVERAGE_VALUE
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#endif
-#ifndef GL_SAMPLER_2D
-#define GL_SAMPLER_2D 0x8B5E
-#endif
-#ifndef GL_SAMPLER_CUBE
-#define GL_SAMPLER_CUBE 0x8B60
-#endif
-#ifndef GL_SAMPLES
-#define GL_SAMPLES 0x80A9
-#endif
-#ifndef GL_SCISSOR_BOX
-#define GL_SCISSOR_BOX 0x0C10
-#endif
-#ifndef GL_SCISSOR_TEST
-#define GL_SCISSOR_TEST 0x0C11
-#endif
-#ifndef GL_SHADER_BINARY_FORMATS
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#endif
-#ifndef GL_SHADER_COMPILER
-#define GL_SHADER_COMPILER 0x8DFA
-#endif
-#ifndef GL_SHADER_SOURCE_LENGTH
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#endif
-#ifndef GL_SHADER_TYPE
-#define GL_SHADER_TYPE 0x8B4F
-#endif
-#ifndef GL_SHADING_LANGUAGE_VERSION
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#endif
-#ifndef GL_SHORT
-#define GL_SHORT 0x1402
-#endif
-#ifndef GL_SRC_ALPHA
-#define GL_SRC_ALPHA 0x0302
-#endif
-#ifndef GL_SRC_ALPHA_SATURATE
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#endif
-#ifndef GL_SRC_COLOR
-#define GL_SRC_COLOR 0x0300
-#endif
-#ifndef GL_STATIC_DRAW
-#define GL_STATIC_DRAW 0x88E4
-#endif
-#ifndef GL_STENCIL_ATTACHMENT
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#endif
-#ifndef GL_STENCIL_BACK_FAIL
-#define GL_STENCIL_BACK_FAIL 0x8801
-#endif
-#ifndef GL_STENCIL_BACK_FUNC
-#define GL_STENCIL_BACK_FUNC 0x8800
-#endif
-#ifndef GL_STENCIL_BACK_PASS_DEPTH_FAIL
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#endif
-#ifndef GL_STENCIL_BACK_PASS_DEPTH_PASS
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#endif
-#ifndef GL_STENCIL_BACK_REF
-#define GL_STENCIL_BACK_REF 0x8CA3
-#endif
-#ifndef GL_STENCIL_BACK_VALUE_MASK
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#endif
-#ifndef GL_STENCIL_BACK_WRITEMASK
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#endif
-#ifndef GL_STENCIL_BITS
-#define GL_STENCIL_BITS 0x0D57
-#endif
-#ifndef GL_STENCIL_BUFFER_BIT
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#endif
-#ifndef GL_STENCIL_CLEAR_VALUE
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#endif
-#ifndef GL_STENCIL_FAIL
-#define GL_STENCIL_FAIL 0x0B94
-#endif
-#ifndef GL_STENCIL_FUNC
-#define GL_STENCIL_FUNC 0x0B92
-#endif
-#ifndef GL_STENCIL_INDEX
-#define GL_STENCIL_INDEX 0x1901
-#endif
-#ifndef GL_STENCIL_INDEX8
-#define GL_STENCIL_INDEX8 0x8D48
-#endif
-#ifndef GL_STENCIL_PASS_DEPTH_FAIL
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#endif
-#ifndef GL_STENCIL_PASS_DEPTH_PASS
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#endif
-#ifndef GL_STENCIL_REF
-#define GL_STENCIL_REF 0x0B97
-#endif
-#ifndef GL_STENCIL_TEST
-#define GL_STENCIL_TEST 0x0B90
-#endif
-#ifndef GL_STENCIL_VALUE_MASK
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#endif
-#ifndef GL_STENCIL_WRITEMASK
-#define GL_STENCIL_WRITEMASK 0x0B98
-#endif
-#ifndef GL_STREAM_DRAW
-#define GL_STREAM_DRAW 0x88E0
-#endif
-#ifndef GL_SUBPIXEL_BITS
-#define GL_SUBPIXEL_BITS 0x0D50
-#endif
-#ifndef GL_TEXTURE0
-#define GL_TEXTURE0 0x84C0
-#endif
-#ifndef GL_TEXTURE
-#define GL_TEXTURE 0x1702
-#endif
-#ifndef GL_TEXTURE10
-#define GL_TEXTURE10 0x84CA
-#endif
-#ifndef GL_TEXTURE1
-#define GL_TEXTURE1 0x84C1
-#endif
-#ifndef GL_TEXTURE11
-#define GL_TEXTURE11 0x84CB
-#endif
-#ifndef GL_TEXTURE12
-#define GL_TEXTURE12 0x84CC
-#endif
-#ifndef GL_TEXTURE13
-#define GL_TEXTURE13 0x84CD
-#endif
-#ifndef GL_TEXTURE14
-#define GL_TEXTURE14 0x84CE
-#endif
-#ifndef GL_TEXTURE15
-#define GL_TEXTURE15 0x84CF
-#endif
-#ifndef GL_TEXTURE16
-#define GL_TEXTURE16 0x84D0
-#endif
-#ifndef GL_TEXTURE17
-#define GL_TEXTURE17 0x84D1
-#endif
-#ifndef GL_TEXTURE18
-#define GL_TEXTURE18 0x84D2
-#endif
-#ifndef GL_TEXTURE19
-#define GL_TEXTURE19 0x84D3
-#endif
-#ifndef GL_TEXTURE20
-#define GL_TEXTURE20 0x84D4
-#endif
-#ifndef GL_TEXTURE2
-#define GL_TEXTURE2 0x84C2
-#endif
-#ifndef GL_TEXTURE21
-#define GL_TEXTURE21 0x84D5
-#endif
-#ifndef GL_TEXTURE22
-#define GL_TEXTURE22 0x84D6
-#endif
-#ifndef GL_TEXTURE23
-#define GL_TEXTURE23 0x84D7
-#endif
-#ifndef GL_TEXTURE24
-#define GL_TEXTURE24 0x84D8
-#endif
-#ifndef GL_TEXTURE25
-#define GL_TEXTURE25 0x84D9
-#endif
-#ifndef GL_TEXTURE26
-#define GL_TEXTURE26 0x84DA
-#endif
-#ifndef GL_TEXTURE27
-#define GL_TEXTURE27 0x84DB
-#endif
-#ifndef GL_TEXTURE28
-#define GL_TEXTURE28 0x84DC
-#endif
-#ifndef GL_TEXTURE29
-#define GL_TEXTURE29 0x84DD
-#endif
-#ifndef GL_TEXTURE_2D
-#define GL_TEXTURE_2D 0x0DE1
-#endif
-#ifndef GL_TEXTURE30
-#define GL_TEXTURE30 0x84DE
-#endif
-#ifndef GL_TEXTURE3
-#define GL_TEXTURE3 0x84C3
-#endif
-#ifndef GL_TEXTURE31
-#define GL_TEXTURE31 0x84DF
-#endif
-#ifndef GL_TEXTURE4
-#define GL_TEXTURE4 0x84C4
-#endif
-#ifndef GL_TEXTURE5
-#define GL_TEXTURE5 0x84C5
-#endif
-#ifndef GL_TEXTURE6
-#define GL_TEXTURE6 0x84C6
-#endif
-#ifndef GL_TEXTURE7
-#define GL_TEXTURE7 0x84C7
-#endif
-#ifndef GL_TEXTURE8
-#define GL_TEXTURE8 0x84C8
-#endif
-#ifndef GL_TEXTURE9
-#define GL_TEXTURE9 0x84C9
-#endif
-#ifndef GL_TEXTURE_BINDING_2D
-#define GL_TEXTURE_BINDING_2D 0x8069
-#endif
-#ifndef GL_TEXTURE_BINDING_CUBE_MAP
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_X
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_X
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Y
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Z
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#endif
-#ifndef GL_TEXTURE_MAG_FILTER
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#endif
-#ifndef GL_TEXTURE_MIN_FILTER
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#endif
-#ifndef GL_TEXTURE_WRAP_S
-#define GL_TEXTURE_WRAP_S 0x2802
-#endif
-#ifndef GL_TEXTURE_WRAP_T
-#define GL_TEXTURE_WRAP_T 0x2803
-#endif
-#ifndef GL_TRIANGLE_FAN
-#define GL_TRIANGLE_FAN 0x0006
-#endif
-#ifndef GL_TRIANGLES
-#define GL_TRIANGLES 0x0004
-#endif
-#ifndef GL_TRIANGLE_STRIP
-#define GL_TRIANGLE_STRIP 0x0005
-#endif
-#ifndef GL_TRUE
-#define GL_TRUE 1
-#endif
-#ifndef GL_UNPACK_ALIGNMENT
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#endif
-#ifndef GL_UNSIGNED_BYTE
-#define GL_UNSIGNED_BYTE 0x1401
-#endif
-#ifndef GL_UNSIGNED_INT
-#define GL_UNSIGNED_INT 0x1405
-#endif
-#ifndef GL_UNSIGNED_SHORT
-#define GL_UNSIGNED_SHORT 0x1403
-#endif
-#ifndef GL_UNSIGNED_SHORT_4_4_4_4
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#endif
-#ifndef GL_UNSIGNED_SHORT_5_5_5_1
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#endif
-#ifndef GL_UNSIGNED_SHORT_5_6_5
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#endif
-#ifndef GL_VALIDATE_STATUS
-#define GL_VALIDATE_STATUS 0x8B83
-#endif
-#ifndef GL_VENDOR
-#define GL_VENDOR 0x1F00
-#endif
-#ifndef GL_VERSION
-#define GL_VERSION 0x1F02
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_ENABLED
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_POINTER
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_SIZE
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_STRIDE
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#endif
-#ifndef GL_VERTEX_ATTRIB_ARRAY_TYPE
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#endif
-#ifndef GL_VERTEX_SHADER
-#define GL_VERTEX_SHADER 0x8B31
-#endif
-#ifndef GL_VIEWPORT
-#define GL_VIEWPORT 0x0BA2
-#endif
-#ifndef GL_ZERO
-#define GL_ZERO 0
-#endif
-
-#endif
diff --git a/src/threed/arrays/arrays.pri b/src/threed/arrays/arrays.pri
deleted file mode 100644
index 978f252d..00000000
--- a/src/threed/arrays/arrays.pri
+++ /dev/null
@@ -1,28 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += \
- arrays/qglattributedescription.h \
- arrays/qglattributeset.h \
- arrays/qglattributevalue.h \
- arrays/qglindexbuffer.h \
- arrays/qglvertexbundle.h \
- arrays/qarray.h \
- arrays/qcolor4ub.h \
- arrays/qcustomdataarray.h \
- arrays/qvector2darray.h \
- arrays/qvector3darray.h \
- arrays/qvector4darray.h
-SOURCES += \
- qglattributedescription.cpp \
- qglattributeset.cpp \
- qglattributevalue.cpp \
- qglindexbuffer.cpp \
- qglvertexbundle.cpp \
- qarray.cpp \
- qcolor4ub.cpp \
- qcustomdataarray.cpp \
- qvector2darray.cpp \
- qvector3darray.cpp \
- qvector4darray.cpp
-PRIVATE_HEADERS += \
- qglvertexbundle_p.h
diff --git a/src/threed/arrays/qarray.cpp b/src/threed/arrays/qarray.cpp
deleted file mode 100644
index e9267ae3..00000000
--- a/src/threed/arrays/qarray.cpp
+++ /dev/null
@@ -1,1022 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qarray.h"
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QArray
- \brief The QArray class is a template class that provides a dynamic array of simple types.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QArray is similar to QVector except that it has much less overhead
- when constructing large arrays by appending individual elements
- one by one.
-
- QArray instances have a preallocated data area for quickly
- building small arrays on the stack without malloc overhead.
- Once the array grows beyond the preallocated size, it is copied
- to the heap. The size of the preallocated area, which defaults to 8,
- can be specified with the second template parameter:
-
- \code
- QArray<QVector3D, 32> array;
- \endcode
-
- QArray uses implicit sharing and copy-on-write semantics to support
- passing large arrays around an application with little overhead.
-
- QArray is heavily optimized for copy-on-write and the case of
- constructing an array by calling append(). It has a slight
- performance penalty for random access using the non-const
- version of operator[]().
-*/
-
-/*!
- \fn QArray::QArray()
-
- Constructs an empty array.
-
- \sa reserve()
-*/
-
-/*!
- \fn QArray::QArray(int size, const T &value)
-
- Constructs an array of \a size elements, all initialized
- to \a value.
-
- \sa fill()
-*/
-
-/*!
- \fn QArray::QArray(int size)
-
- Constructs an array of \a size elements, all initialized
- to their default-constructed values.
-*/
-
-/*!
- \fn QArray::QArray(const T *values, int size)
-
- Constructs an array of \a size elements, initialized
- from \a values.
-*/
-
-/*!
- \fn QArray::QArray(const QArray<T, PreallocSize> &other)
-
- Constructs a copy of \a other.
-
- \sa operator=()
-*/
-
-/*!
- \fn QArray::~QArray()
-
- Destroys the array.
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::operator=(const QArray<T, PreallocSize> &other)
-
- Assigns \a other to this array and returns a reference
- to this array.
-*/
-
-/*!
- \fn int QArray::size() const
-
- Returns the number of elements in this array.
-
- \sa resize(), capacity(), isEmpty()
-*/
-
-/*!
- \fn int QArray::count() const
- \overload
-
- Same as size(), provided for convenience.
-*/
-
-/*!
- \fn int QArray::capacity() const
-
- Returns the number of elements that can be stored in this
- array before reallocation.
-
- \sa reserve(), size()
-*/
-
-/*!
- \fn bool QArray::isEmpty() const
-
- Returns true if this array is empty; false otherwise.
-
- \sa size(), clear()
-*/
-
-/*!
- \fn bool QArray::isDetached() const
- \internal
-
- Returns true if this array has definitely been detached from all
- other shared copies of the data; false otherwise.
-
- It is possible for this function to return false if the
- array was previously shared but no longer is. It is thus
- an indication that a detach() will probably be required.
-
- This function can be used to determine if functions that
- write to this array such as append(), replace(),
- and data(), will need to make a copy.
-
- Raw data arrays that are created with fromRawData() are
- never detached.
-
- \sa detach()
-*/
-
-/*!
- \fn void QArray::detach()
- \internal
-
- Detaches this array from all other shared copies of the data.
-
- \sa isDetached()
-*/
-
-/*!
- \fn void QArray::clear()
-
- Clears all elements from this array and sets the size to zero.
-
- This function will deallocate any memory that is used on the heap
- to store the array's elements. To reuse the same memory
- as before, call resize() with an argument of zero.
-
- \sa resize(), isEmpty()
-*/
-
-/*!
- \fn const T &QArray::at(int index) const
-
- Returns the item at position \a index in the array.
-
- \a index must be a valid index position in the array (i.e., 0 <= \a
- index < size()).
-
- \sa operator[](), constData(), value()
-*/
-
-/*!
- \fn T &QArray::operator[](int index)
-
- Returns the item at position \a index as a modifiable reference.
-
- \a index must be a valid index position in the vector (i.e., 0 <= \a index
- < size()).
-
- Note that using non-const operators can cause QArray
- to do a deep copy.
-
- \sa at(), value()
-*/
-
-/*!
- \fn const T &QArray::operator[](int index) const
-
- \overload
-
- Same as at(\a index).
-*/
-
-/*!
- \fn T QArray::value(int index) const
-
- Returns the value at position \a index in the vector.
-
- If the \a index is out of bounds, the function returns
- a default-constructed value. If you are certain that
- \a index is within bounds, you can use at() instead,
- which is slightly faster.
-
- \sa at(), operator[]()
-*/
-
-/*!
- \fn T QArray::value(int index, const T &defaultValue) const
- \overload
-
- If the \a index is out of bounds, the function returns
- \a defaultValue.
-*/
-
-/*!
- \fn T *QArray::extend(int size)
-
- Extends this array by \a size elements and returns a pointer
- to the storage, which is not initialized. The pointer is only
- valid until the array is reallocated or destroyed.
-
- The append() or resize() functions are recommended if T is a
- complex type, with extend() only used for simple types.
- Because the storage is not initialized, the caller should use
- the in-place new operator to set elements:
-
- \code
- QArray<QRegExp> array;
- QRegExp *space = array.extend(1);
- new (space) QRegExp(QLatin1String("exp"));
- \endcode
-
- \sa append(), resize()
-*/
-
-/*!
- \fn void QArray::append(const T &value)
-
- Appends \a value to this array.
-
- \sa prepend(), insert()
-*/
-
-/*!
- \fn void QArray::append(const T &value1, const T &value2)
-
- \overload
-
- Appends \a value1 and \a value2 to this array.
-*/
-
-/*!
- \fn void QArray::append(const T &value1, const T &value2, const T &value3)
-
- \overload
-
- Appends \a value1, \a value2, and \a value3 to this array.
-*/
-
-/*!
- \fn void QArray::append(const T &value1, const T &value2, const T &value3, const T &value4)
-
- \overload
-
- Appends \a value1, \a value2, \a value3, and \a value4 to this array.
-*/
-
-/*!
- \fn void QArray::append(const T *values, int count)
-
- Appends the \a count elements of \a values to this array.
-*/
-
-/*!
- \fn void QArray::append(const QArray<T, PreallocSize> &other)
-
- Appends the elements of \a other to this array.
-*/
-
-/*!
- \fn void QArray::prepend(const T &value)
-
- Prepends \a value to this array.
-
- \sa append(), insert()
-*/
-
-/*!
- \fn void QArray::insert(int index, const T &value)
-
- Inserts \a value at position \a index in this array.
- If \a index is 0, then \a value is prepended to the array.
- If \a index is size(), then \a value is appended to the array.
-
- \sa append(), prepend()
-*/
-
-/*!
- \fn void QArray::insert(int index, int count, const T &value)
- \overload
-
- Inserts \a count copies of \a value at position \a index
- in this array.
-*/
-
-/*!
- \fn QArray::iterator QArray::insert(iterator before, int count, const T &value)
-
- Inserts \a count copies of \a value in front of the item
- pointed to by the iterator \a before. Returns an iterator
- pointing at the first of the inserted items.
-*/
-
-/*!
- \fn QArray::iterator QArray::insert(iterator before, const T &value)
- \overload
-
- Inserts \a value in front of the item pointed to by the
- iterator \a before. Returns an iterator pointing at the
- inserted item.
-*/
-
-/*!
- \fn void QArray::replace(int index, const T &value)
-
- Replaces the element at \a index with \a value.
-
- \sa operator[](), remove()
-*/
-
-/*!
- \fn void QArray::replace(int index, const T *values, int count)
- \overload
-
- Replaces the \a count elements of this array with the
- contents of \a values, starting at \a index.
-
- If (\a index + \a count) is larger than the current size of this
- array, the array will be extended to that size.
-
- \sa append()
-*/
-
-/*!
- \fn void QArray::remove(int index)
-
- \overload
-
- Removes the element at position \a index in this array.
-*/
-
-/*!
- \fn void QArray::remove(int index, int count)
-
- Removes the \a count elements starting at position \a index
- in this array. If \a index or \a count is out of range,
- the set of removed elements will be truncated to those that
- are in range.
-*/
-
-/*!
- \fn QArray::iterator QArray::erase(iterator begin, iterator end)
- \overload
-
- Removes all the items from \a begin up to (but not including) \a
- end. Returns an iterator to the same item that \a end referred to
- before the call.
-*/
-
-/*!
- \fn QArray::iterator QArray::erase(iterator pos)
-
- Removes the item pointed to by the iterator \a pos from the
- vector, and returns an iterator to the next item in the vector
- (which may be end()).
-
- \sa insert(), remove()
-*/
-
-/*!
- \fn void QArray::removeFirst()
-
- Removes the first element from this array. Does nothing if
- the array is empty.
-
- \sa remove(), removeLast()
-*/
-
-/*!
- \fn void QArray::removeLast()
-
- Removes the last element from this array. Does nothing if
- the array is empty.
-
- \sa remove(), removeFirst()
-*/
-
-/*!
- \fn int QArray::indexOf(const T &value, int from) const
-
- Returns the index position of the first occurrence of
- \a value in the array, searching forward from index
- position \a from. Returns -1 if no item matched.
-
- If \a from is negative, then it indicates an index position
- relative to the end of the array, -1 being the last index
- position.
-
- This function requires the value type T to have an implementation
- of \c operator==().
-
- \sa lastIndexOf(), contains()
-*/
-
-/*!
- \fn int QArray::lastIndexOf(const T &value, int from) const
-
- Returns the index position of the last occurrence of
- \a value in the array, searching backward from index
- position \a from. Returns -1 if no item matched.
-
- If \a from is negative, then it indicates an index position
- relative to the end of the array, -1 being the last index
- position. The default for \a from is -1.
-
- This function requires the value type T to have an implementation
- of \c operator==().
-
- \sa indexOf(), contains()
-*/
-
-/*!
- \fn bool QArray::contains(const T &value) const
-
- Returns true if the array contains an occurrence of \a value;
- false otherwise.
-
- This function requires the value type T to have an implementation
- of \c operator==().
-
- \sa indexOf(), count()
-*/
-
-/*!
- \fn int QArray::count(const T &value) const
-
- Returns the number of occurrences of \a value in the array.
-
- This function requires the value type T to have an implementation
- of \c operator==().
-
- \sa contains(), indexOf()
-*/
-
-/*!
- \fn void QArray::resize(int size)
-
- Sets the size of the array to \a size. If \a size is greater
- than the current size, elements are added to the end and are
- initialized to a default-constructed value. If \a size is less
- than the current size, elements are removed from the end.
-
- \sa size(), reserve(), squeeze()
-*/
-
-/*!
- \fn void QArray::reserve(int size)
-
- Increases the capacity of this array to reserve space for
- at least \a size elements. If the capacity is already larger
- than \a size, this function does nothing; in particular, it does
- not remove elements from the array like resize() does.
-
- This function can be useful when you know how roughly many elements
- will be appended ahead of time. Reserving the space once can avoid
- unnecessary realloc operations later.
-
- \sa capacity(), resize(), squeeze()
-*/
-
-/*!
- \fn void QArray::squeeze()
-
- Releases any memory not required to store the array's elements
- by reducing its capacity() to size().
-
- This function is intended for reclaiming memory in an
- array that is being used over and over with different contents.
- As elements are added to an array, it will be constantly
- expanded in size. This function can realloc the array
- to a smaller size to reclaim unused memory.
-
- \sa reserve(), capacity()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::fill(const T &value, int size)
-
- Assigns \a value to all items in the array. If \a size is
- different from -1 (the default), the array is resized to
- \a size beforehand. Returns a reference to the array.
-
- \sa resize()
-*/
-
-/*!
- \fn void QArray::reverse()
-
- Reverses the order of this array in place.
-
- \sa reversed()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::reversed() const
-
- Returns a copy of this array with elements in the reverse order.
-
- \sa reverse()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::mid(int index, int length) const
-
- Returns an array containing the \a length elements of
- this array, starting at \a index. If \a length is less
- than zero, or extends further than the end of the array, then all
- elements extending from \a index to the end of the array will be
- included in the return value.
-
- \sa left(), right()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::left(int length) const;
-
- Returns an array containing the first \a length
- elements of this array. If \a length is less than zero,
- or greater than size(), then all elements in this array will
- be included in the return value.
-
- \sa mid(), right()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::right(int length) const;
-
- Returns an array containing the last \a length
- elements of this array. If \a length is less than zero,
- or greater than size(), then all elements in this array
- will be included in the return value.
-
- \sa mid(), left()
-*/
-
-/*!
- \fn T *QArray::data()
-
- Returns a pointer to the data stored in the array. The pointer
- can be used to access and modify the items in the array.
-
- The pointer remains valid as long as the array isn't
- reallocated.
-
- This function is mostly useful to pass an array to a function
- that accepts a plain C++ array. It may make a deep copy of the
- array's elements if the array is implicitly shared.
-
- \sa constData(), operator[]()
-*/
-
-/*!
- \fn const T *QArray::data() const
-
- \overload
-*/
-
-/*!
- \fn const T *QArray::constData() const
-
- Returns a const pointer to the data stored in the array.
- The pointer can be used to access the items in the array.
- The pointer remains valid as long as the array isn't
- reallocated.
-
- This function is mostly useful to pass an array to a function
- that accepts a plain C++ array.
-
- \sa data(), operator[]()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::fromRawData(const T *data, int size)
-
- Returns an array consisting of the \a size elements from \a data.
-
- This function takes a reference to \a data, but does not copy
- the elements until the array is modified. The memory at \a data
- must remain valid until the returned array is destroyed
- or modified.
-
- Use append() instead of fromRawData() to force a copy to be made
- of the elements at \a data when the array is created:
-
- \code
- // Makes a copy of the data immediately.
- QArray<float> array;
- array.append(data, size);
-
- // Does not make a copy of the data until the array is modified.
- QArray<float> array;
- array = QArray<float>::fromRawData(data, size);
- \endcode
-
- \sa fromWritableRawData(), append()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> QArray::fromWritableRawData(T *data, int size)
-
- Returns an array consisting of the \a size elements from \a data.
-
- This function takes a reference to \a data, but does not copy
- the elements until the array is reallocated to a larger size.
- The memory at \a data must remain valid until the returned
- array is destroyed or reallocated.
-
- The elements of \a data will be modified in-place. This differs
- from fromRawData() which will make a copy of the elements
- of \a data when the array is modified.
-
- If the returned array is resized to less than \a size,
- then a copy will not be made, and append() can be used to
- append new items up to \a size. Further calls to append()
- after \a size will force the array to be reallocated.
-
- If the returned array is resized to more than \a size,
- then a copy of the data will be made and further modifications
- will not affect the elements at \a data.
-
- \sa fromRawData()
-*/
-
-/*!
- \fn bool QArray::operator==(const QArray<T, PreallocSize> &other) const
-
- Returns true if \a other is equal to this array; otherwise
- returns false.
-
- Two arrays are considered equal if they contain the same values
- in the same order.
-
- This function requires the value type to have an implementation
- of \c operator==().
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QArray::operator!=(const QArray<T, PreallocSize> &other) const
-
- Returns true if \a other is not equal to this array; otherwise
- returns false.
-
- Two arrays are considered equal if they contain the same values
- in the same order.
-
- This function requires the value type to have an implementation
- of \c operator==().
-
- \sa operator==()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::operator+=(const T &value)
-
- \overload
-
- Appends \a value to this array and returns a reference to
- this array.
-
- \sa operator<<(), append()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::operator+=(const QArray<T, PreallocSize> &other)
-
- Appends the elements of the \a other array to this array
- and returns a reference to this array.
-
- \sa operator<<(), append()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::operator<<(const T &value)
-
- \overload
-
- Appends \a value to this array and returns a reference to
- this array.
-
- \sa operator+=(), append()
-*/
-
-/*!
- \fn QArray<T, PreallocSize> &QArray::operator<<(const QArray<T, PreallocSize> &other)
-
- Appends the elements of the \a other array to this array
- and returns a reference to this array.
-
- \sa operator+=(), append()
-*/
-
-/*!
- \typedef QArray::iterator
-
- The QArray::iterator typedef provides an STL-style non-const
- iterator for QArray. The iterator is simply a typedef
- for "T *" (pointer to T).
-
- \sa QArray::begin(), QArray::const_iterator
-*/
-
-/*!
- \typedef QArray::const_iterator
-
- The QArray::iterator typedef provides an STL-style const
- iterator for QArray. The iterator is simply a typedef
- for "const T *" (pointer to const T).
-
- \sa QArray::constBegin(), QArray::iterator
-*/
-
-/*!
- \typedef QArray::Iterator
-
- Qt-style synonym for QArray::iterator.
-*/
-
-/*!
- \typedef QArray::ConstIterator
-
- Qt-style synonym for QArray::const_iterator.
-*/
-
-/*!
- \typedef QArray::const_pointer
-
- Typedef for const T *. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::const_reference
-
- Typedef for T &. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::difference_type
-
- Typedef for ptrdiff_t. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::pointer
-
- Typedef for T *. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::reference
-
- Typedef for T &. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::size_type
-
- Typedef for int. Provided for STL compatibility.
-*/
-
-/*!
- \typedef QArray::value_type
-
- Typedef for T. Provided for STL compatibility.
-*/
-
-/*!
- \fn QArray::iterator QArray::begin()
-
- Returns an STL-style iterator pointing to the first item
- in the array.
-
- \sa end(), constBegin(), QArray::iterator
-*/
-
-/*!
- \fn QArray::const_iterator QArray::begin() const
- \overload
-*/
-
-/*!
- \fn QArray::const_iterator QArray::constBegin() const
-
- Returns a const STL-style iterator pointing to the first item
- in the array.
-
- \sa constEnd(), begin(), QArray::const_iterator
-*/
-
-/*!
- \fn QArray::iterator QArray::end()
-
- Returns an STL-style iterator pointing to the imaginary item
- after the last item in the array.
-
- \sa begin(), constEnd(), QArray::iterator
-*/
-
-/*!
- \fn QArray::const_iterator QArray::end() const
- \overload
-*/
-
-/*!
- \fn QArray::const_iterator QArray::constEnd() const
-
- Returns a const STL-style iterator pointing to the imaginary item
- after the last item in the array.
-
- \sa constBegin(), end(), QArray::const_iterator
-*/
-
-/*!
- \fn T &QArray::first()
-
- Returns a reference to the first item in the array. This
- function assumes that the array isn't empty.
-
- \sa last(), isEmpty()
-*/
-
-/*!
- \fn const T &QArray::first() const
- \overload
-*/
-
-/*!
- \fn T &QArray::last()
-
- Returns a reference to the last item in the array. This function
- assumes that the array isn't empty.
-
- \sa first(), isEmpty()
-*/
-
-/*!
- \fn const T &QArray::last() const
- \overload
-*/
-
-/*!
- \fn bool QArray::startsWith(const T &value) const
-
- Returns true if this array is not empty and its first
- item is equal to \a value; otherwise returns false.
-
- \sa isEmpty(), first()
-*/
-
-/*!
- \fn bool QArray::endsWith(const T &value) const
-
- Returns true if this array is not empty and its last
- item is equal to \a value; otherwise returns false.
-
- \sa isEmpty(), last()
-*/
-
-/*!
- \fn void QArray::push_back(const T &value)
-
- This function is provided for STL compatibility. It is equivalent
- to append(\a value).
-*/
-
-/*!
- \fn void QArray::push_front(const T &value)
-
- This function is provided for STL compatibility. It is equivalent
- to prepend(\a value).
-*/
-
-/*!
- \fn void QArray::pop_front()
-
- This function is provided for STL compatibility. It is equivalent
- to removeFirst().
-*/
-
-/*!
- \fn void QArray::pop_back()
-
- This function is provided for STL compatibility. It is equivalent
- to removeLast().
-*/
-
-/*!
- \fn QArray::reference QArray::front()
-
- This function is provided for STL compatibility. It is equivalent
- to first().
-*/
-
-/*!
- \fn QArray::const_reference QArray::front() const
- \overload
-*/
-
-/*!
- \fn QArray::reference QArray::back()
-
- This function is provided for STL compatibility. It is equivalent
- to last().
-*/
-
-/*!
- \fn QArray::const_reference QArray::back() const
- \overload
-*/
-
-/*!
- \fn bool QArray::empty() const
-
- This function is provided for STL compatibility. It is equivalent
- to isEmpty(), returning true if the array is empty; otherwise
- returns false.
-*/
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream& operator<<(QDataStream& stream, const QArray<T, PreallocSize>& array)
- \relates QArray
-
- Writes \a array to the given \a stream and returns a reference
- to the \a stream.
-*/
-
-/*!
- \fn QDataStream& operator>>(QDataStream& stream, QArray<T, PreallocSize>& array)
- \relates QArray
-
- Reads \a array from the given \a stream and returns a reference
- to the \a stream.
-*/
-
-#endif
-
-int qArrayAllocMore(int alloc, int extra, int sizeOfT)
-{
- if (alloc == 0 && extra == 0)
- return 0;
- const int page = 1 << 12;
- int nalloc;
- alloc += extra;
- alloc *= sizeOfT;
- // don't do anything if the loop will overflow signed int.
- if (alloc >= INT_MAX/2)
- return INT_MAX / sizeOfT;
- nalloc = (alloc < page) ? 64 : page;
- while (nalloc < alloc) {
- if (nalloc <= 0)
- return INT_MAX / sizeOfT;
- nalloc *= 2;
- }
- return nalloc / sizeOfT;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qarray.h b/src/threed/arrays/qarray.h
deleted file mode 100644
index ed6e32f5..00000000
--- a/src/threed/arrays/qarray.h
+++ /dev/null
@@ -1,1209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QARRAY_H
-#define QARRAY_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qatomic.h>
-#include <QtCore/qdatastream.h>
-#include <QtCore/qdebug.h>
-#include <string.h>
-#include <new>
-
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-#if defined(Q_DECL_ALIGN) && defined(Q_ALIGNOF)
-
-#if defined(Q_CC_GNU) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
- typedef char __attribute__((__may_alias__)) QArrayAlignedChar;
-#else
- typedef char QArrayAlignedChar;
-#endif
-
-template <typename T, int PreallocSize, size_t AlignT>
-struct QArrayAlignedPrealloc;
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 1>
-{
- QArrayAlignedChar Q_DECL_ALIGN(1) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 2>
-{
- QArrayAlignedChar Q_DECL_ALIGN(2) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 4>
-{
- QArrayAlignedChar Q_DECL_ALIGN(4) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 8>
-{
- QArrayAlignedChar Q_DECL_ALIGN(8) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 16>
-{
- QArrayAlignedChar Q_DECL_ALIGN(16) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 32>
-{
- QArrayAlignedChar Q_DECL_ALIGN(32) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 64>
-{
- QArrayAlignedChar Q_DECL_ALIGN(64) data[sizeof(T) * PreallocSize];
-};
-template <typename T, int PreallocSize>
-struct QArrayAlignedPrealloc<T, PreallocSize, 128>
-{
- QArrayAlignedChar Q_DECL_ALIGN(128) data[sizeof(T) * PreallocSize];
-};
-
-#else
-
-template <typename T, int PreallocSize, size_t AlignT>
-union QArrayAlignedPrealloc
-{
- char data[sizeof(T) * PreallocSize];
- qint64 q_for_alignment_1;
- double q_for_alignment_2;
-};
-
-#endif
-
-template <typename T, int PreallocSize>
-class QArrayData
-{
-public:
-#if defined(Q_ALIGNOF)
- QArrayAlignedPrealloc<T, PreallocSize, Q_ALIGNOF(T)> m_prealloc;
-#else
- QArrayAlignedPrealloc<T, PreallocSize, sizeof(T)> m_prealloc;
-#endif
-
- inline T *prealloc()
- {
- return reinterpret_cast<T *>(m_prealloc.data);
- }
-
- inline bool isPrealloc(const T *start) const
- {
- return start == reinterpret_cast<const T *>(m_prealloc.data);
- }
-};
-
-template <typename T>
-class QArrayData<T, 0>
-{
-public:
-
- inline T *prealloc() { return 0; }
-
- inline bool isPrealloc(const T *start) const
- {
- Q_UNUSED(start);
- return false;
- }
-};
-
-template <typename T, int PreallocSize = 8>
-class QArray : private QArrayData<T, PreallocSize>
-{
-public:
- QArray();
- explicit QArray(int size);
- QArray(int size, const T &value);
- QArray(const T *values, int size);
- QArray(const QArray<T, PreallocSize> &other);
- ~QArray();
-
- typedef T *iterator;
- typedef const T *const_iterator;
-
- QArray<T, PreallocSize> &operator=
- (const QArray<T, PreallocSize> &other);
-
- int size() const;
- int count() const;
- int capacity() const;
-
- bool isEmpty() const;
-
- bool isDetached() const;
- void detach();
-
- void clear();
-
- const T &at(int index) const;
- const T &operator[](int index) const;
- T &operator[](int index);
-
- T value(int index) const;
- T value(int index, const T &defaultValue) const;
-
- T *extend(int size);
-
- void append(const T &value);
- void append(const T &value1, const T &value2);
- void append(const T &value1, const T &value2, const T &value3);
- void append(const T &value1, const T &value2, const T &value3, const T &value4);
- void append(const T *values, int count);
- void append(const QArray<T, PreallocSize> &other);
-
- void prepend(const T &value);
-
- void insert(int index, const T &value);
- void insert(int index, int count, const T &value);
- iterator insert(iterator before, int count, const T &value);
- iterator insert(iterator before, const T &value);
-
- void replace(int index, const T &value);
- void replace(int index, const T *values, int count);
-
- void remove(int index);
- void remove(int index, int count);
- void removeFirst() { remove(0); }
- void removeLast() { remove(size() - 1); }
-
- iterator erase(iterator begin, iterator end);
- iterator erase(iterator pos);
-
- int indexOf(const T &value, int from = 0) const;
- int lastIndexOf(const T &value, int from = -1) const;
- bool contains(const T &value) const;
- int count(const T &value) const;
-
- void resize(int size);
- void reserve(int size);
- void squeeze();
-
- QArray<T, PreallocSize> &fill(const T &value, int size = -1);
-
- void reverse();
- QArray<T, PreallocSize> reversed() const;
-
- QArray<T, PreallocSize> mid(int index, int length = -1) const;
- QArray<T, PreallocSize> left(int length) const;
- QArray<T, PreallocSize> right(int length) const;
-
- T *data();
- const T *data() const;
- const T *constData() const;
-
- static QArray<T, PreallocSize> fromRawData(const T *data, int size);
- static QArray<T, PreallocSize> fromWritableRawData(T *data, int size);
-
- bool operator==(const QArray<T, PreallocSize> &other) const;
- bool operator!=(const QArray<T, PreallocSize> &other) const;
-
- QArray<T, PreallocSize> &operator+=(const T &value);
- QArray<T, PreallocSize> &operator+=(const QArray<T, PreallocSize> &other);
- QArray<T, PreallocSize> &operator<<(const T &value);
- QArray<T, PreallocSize> &operator<<(const QArray<T, PreallocSize> &other);
-
- typedef iterator Iterator;
- typedef const_iterator ConstIterator;
- typedef T value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type &reference;
- typedef const value_type &const_reference;
- typedef ptrdiff_t difference_type;
- typedef int size_type;
-
- inline iterator begin() { return data(); }
- inline const_iterator begin() const { return constData(); }
- inline const_iterator constBegin() const { return constData(); }
- inline iterator end() { return data() + size(); }
- inline const_iterator end() const { return constData() + size(); }
- inline const_iterator constEnd() const { return constData() + size(); }
-
- inline T &first() { Q_ASSERT(!isEmpty()); return *begin(); }
- inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
- inline T &last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
- inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
- inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
- inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
-
- inline void push_back(const T &value) { append(value); }
- inline void push_front(const T &value) { prepend(value); }
- inline void pop_back() { Q_ASSERT(!isEmpty()); removeLast(); }
- inline void pop_front() { Q_ASSERT(!isEmpty()); removeFirst(); }
- inline bool empty() const { return isEmpty(); }
- inline reference front() { return first(); }
- inline const_reference front() const { return first(); }
- inline reference back() { return last(); }
- inline const_reference back() const { return last(); }
-
-private:
- struct Data
- {
- QBasicAtomicInt ref;
- int capacity;
- T array[1];
- };
-
- // Invariants:
- // 1. If the data is not shared, then the usual condition is
- // for m_limit >= m_end.
- // 2. If the data is shared, then m_limit == m_start.
- // This triggers the range check in append() to call grow(),
- // which will copy-on-write. It also triggers the detach
- // check in data() and operator[] to cause a copy-on-write.
- // 3. If the data is not shared, but previously was, then
- // m_limit == m_start. This will trigger grow() or
- // detach(), which may then notice that it doesn't have to
- // copy-on-write. In that case, m_limit is set back
- // to m_start + m_data->capacity.
- // 4. If m_data is null, then m_start is either the same as
- // m_prealloc, or it points at raw data (const or non-const).
- // 5. If the array contains const raw data, then m_limit will
- // be set to m_start to force copy-on-write.
- T *m_start;
- T *m_end;
- mutable T *m_limit;
- Data *m_data;
-
- inline void initPrealloc()
- {
- m_end = m_start = QArrayData<T, PreallocSize>::prealloc();
- m_limit = m_start + PreallocSize;
- }
-
- QArray(const T *data, int size, bool isWritable);
-
- void free(T *data, int count);
- void release();
- void copyReplace(T *dst, const T *src, int count);
- Data *copyData(const T *src, int size, int capacity);
- void reallocate(int capacity);
- void detach_helper();
- void assign(const QArray<T, PreallocSize> &other);
- void grow(int needed);
- void setSize(int size);
-};
-
-int Q_QT3D_EXPORT qArrayAllocMore(int alloc, int extra, int sizeOfT);
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::free(T *data, int count)
-{
- while (count-- > 0) {
- data->~T();
- ++data;
- }
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::release()
-{
- if (m_data) {
- if (!m_data->ref.deref()) {
- if (QTypeInfo<T>::isComplex)
- free(m_start, m_end - m_start);
- qFree(m_data);
- }
- } else if (this->isPrealloc(m_start)) {
- if (QTypeInfo<T>::isComplex)
- free(m_start, m_end - m_start);
- }
-}
-
-// Copy values to initialized memory, replacing previous values.
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::copyReplace(T *dst, const T *src, int count)
-{
- if (!QTypeInfo<T>::isStatic) {
- ::memmove(dst, src, count * sizeof(T));
- } else {
- while (count-- > 0)
- *dst++ = *src++;
- }
-}
-
-// Make a copy of m_data, while remaining exception-safe.
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE Q_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)));
- Q_CHECK_PTR(data);
- data->ref = 1;
- data->capacity = capacity;
- T *dst = data->array;
- int copied = 0;
- QT_TRY {
- while (copied < size) {
- new (dst) T(*src++);
- ++dst;
- ++copied;
- }
- } QT_CATCH(...) {
- while (copied-- > 0)
- (--dst)->~T();
- qFree(data);
- QT_RETHROW;
- }
- return data;
-}
-
-template <typename T, int PreallocSize>
-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)));
- 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);
- m_data = data;
- }
- m_start = m_data->array;
- m_end = m_start + size;
- m_limit = m_start + capacity;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::detach_helper()
-{
- // If the reference count is 1, then the array may have been
- // copied and then the copy released. So just reset the limit.
- if (m_data && m_data->ref == 1) {
- m_limit = m_start + m_data->capacity;
- return;
- }
-
- // Allocate a new block on the heap and copy the data across.
- int size = m_end - m_start;
- int capacity = qArrayAllocMore(size, 0, sizeof(T));
- m_data = copyData(m_start, size, capacity);
-
- // Update the start/end/append pointers for faster updates.
- m_start = m_data->array;
- m_end = m_start + size;
- m_limit = m_start + capacity;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::assign(const QArray<T, PreallocSize> &other)
-{
- if (other.m_data) {
- m_start = other.m_start;
- m_end = other.m_end;
- m_data = other.m_data;
- m_data->ref.ref();
-
- // We set the append limit of both objects to m_start, which forces
- // the next append() or data() in either object to copy-on-write.
- other.m_limit = m_limit = m_start;
- } else if (other.isPrealloc(other.m_start)) {
- // Make a deep copy of preallocated data.
- initPrealloc();
- m_data = 0;
- append(other.constData(), other.size());
- } else {
- // Shallow copy of raw data.
- m_start = other.m_start;
- m_end = other.m_end;
- m_limit = other.m_limit;
- m_data = 0;
- }
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::grow(int needed)
-{
- int size = m_end - m_start;
- int capacity = qArrayAllocMore(size, needed, sizeof(T));
- if (!m_data || m_data->ref != 1) {
- // Copy preallocated, raw, or shared data and expand the capacity.
- Data *data = copyData(m_start, size, capacity);
- if (this->isPrealloc(m_start))
- free(m_start, size);
- if (m_data)
- m_data->ref.deref();
- m_data = data;
- m_start = data->array;
- m_end = m_start + size;
- m_limit = m_start + capacity;
- } else if ((size + needed) > m_data->capacity) {
- // Reallocate to create more capacity.
- reallocate(capacity);
- } else {
- // We have enough capacity - just fix the append limit.
- // This can happen when an array is copied and then the
- // copy is removed.
- m_limit = m_start + m_data->capacity;
- }
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::setSize(int size)
-{
- if (size <= PreallocSize) {
- initPrealloc();
- m_data = 0;
- } else {
- int capacity = qArrayAllocMore(size, 0, sizeof(T));
- Data *data = reinterpret_cast<Data *>
- (qMalloc(sizeof(Data) + sizeof(T) * (capacity - 1)));
- Q_CHECK_PTR(data);
- m_data = data;
- m_data->ref = 1;
- m_data->capacity = capacity;
- m_start = m_data->array;
- m_end = m_start;
- m_limit = m_start + capacity;
- }
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray()
-{
- initPrealloc();
- m_data = 0;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray(int size)
-{
- setSize(size);
- while (size-- > 0)
- new (m_end++) T();
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray(int size, const T &value)
-{
- setSize(size);
- while (size-- > 0)
- new (m_end++) T(value);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray(const T *values, int size)
-{
- setSize(size);
- while (size-- > 0)
- new (m_end++) T(*values++);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray(const QArray<T, PreallocSize> &other)
-{
- assign(other);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::QArray(const T *data, int size, bool isWritable)
-{
- // Constructing a raw data array.
- m_start = const_cast<T *>(data);
- m_end = m_start + size;
- if (isWritable)
- m_limit = m_end;
- else
- m_limit = m_start;
- m_data = 0;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize>::~QArray()
-{
- release();
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::operator=(const QArray<T, PreallocSize> &other)
-{
- if (this == &other)
- return *this;
- if (other.m_data && m_data == other.m_data)
- return *this;
- release();
- assign(other);
- return *this;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE int QArray<T, PreallocSize>::size() const
-{
- return m_end - m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE int QArray<T, PreallocSize>::count() const
-{
- return m_end - m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE int QArray<T, PreallocSize>::capacity() const
-{
- if (m_data)
- return m_data->capacity;
- else if (this->isPrealloc(m_start))
- return PreallocSize;
- else
- return m_end - m_start; // raw data, m_limit == m_start
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE bool QArray<T, PreallocSize>::isEmpty() const
-{
- return m_start == m_end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE bool QArray<T, PreallocSize>::isDetached() const
-{
- // If m_limit is the same as m_start, then the array
- // is either shared or contains raw data.
- return m_limit != m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::detach()
-{
- if (m_limit == m_start)
- detach_helper();
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::clear()
-{
- release();
- initPrealloc();
- m_data = 0;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE const T &QArray<T, PreallocSize>::operator[](int index) const
-{
- Q_ASSERT_X(index >= 0 && index < size(),
- "QArray<T>::at", "index out of range");
- return m_start[index];
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE const T &QArray<T, PreallocSize>::at(int index) const
-{
- Q_ASSERT_X(index >= 0 && index < size(),
- "QArray<T>::operator[]", "index out of range");
- return m_start[index];
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE T &QArray<T, PreallocSize>::operator[](int index)
-{
- Q_ASSERT_X(index >= 0 && index < size(),
- "QArray<T>::operator[]", "index out of range");
- return data()[index];
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE T QArray<T, PreallocSize>::value(int index) const
-{
- if (index >= 0 && index < size())
- return m_start[index];
- else
- return T();
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE T QArray<T, PreallocSize>::value(int index, const T &defaultValue) const
-{
- if (index >= 0 && index < size())
- return m_start[index];
- else
- return defaultValue;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE T *QArray<T, PreallocSize>::extend(int size)
-{
- Q_ASSERT(size > 0);
- if ((m_end + size) >= m_limit)
- grow(size);
- T *end = m_end;
- m_end += size; // Note: new elements are not initialized.
- return end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::append(const T &value)
-{
- if (m_end >= m_limit)
- grow(1);
- new (m_end) T(value);
- ++m_end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::append(const T &value1, const T &value2)
-{
- if ((m_end + 1) >= m_limit)
- grow(2);
- new (m_end) T(value1);
- ++m_end; // Increment one at a time in case an exception is thrown.
- new (m_end) T(value2);
- ++m_end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::append(const T &value1, const T &value2, const T &value3)
-{
- if ((m_end + 2) >= m_limit)
- grow(3);
- new (m_end) T(value1);
- ++m_end;
- new (m_end) T(value2);
- ++m_end;
- new (m_end) T(value3);
- ++m_end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::append(const T &value1, const T &value2, const T &value3, const T &value4)
-{
- if ((m_end + 3) >= m_limit)
- grow(4);
- new (m_end) T(value1);
- ++m_end;
- new (m_end) T(value2);
- ++m_end;
- new (m_end) T(value3);
- ++m_end;
- new (m_end) T(value4);
- ++m_end;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::append(const T *values, int count)
-{
- if (count <= 0)
- return;
- if (!m_start || (m_end + count) > m_limit)
- grow(count);
- while (count-- > 0) {
- new (m_end) T(*values++);
- ++m_end;
- }
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::append(const QArray<T, PreallocSize> &other)
-{
- if (isEmpty()) {
- *this = other;
- } else {
- if (&other == this || (m_data && other.m_data == m_data))
- grow(size()); // Appending to ourselves: make some room.
- append(other.constData(), other.size());
- }
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::prepend(const T &value)
-{
- insert(begin(), 1, value);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::insert(int index, const T &value)
-{
- Q_ASSERT_X(index >= 0 && index <= size(),
- "QArray<T>::insert", "index out of range");
- insert(begin() + index, 1, value);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::insert(int index, int count, const T &value)
-{
- Q_ASSERT_X(index >= 0 && index <= size(),
- "QArray<T>::insert", "index out of range");
- insert(begin() + index, count, value);
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE Q_TYPENAME QArray<T, PreallocSize>::iterator QArray<T, PreallocSize>::insert(iterator before, int count, const T &value)
-{
- // Check the parameters.
- int size = this->size();
- int offset = int(before - m_start);
- Q_ASSERT_X(offset >= 0 && offset <= size,
- "QArray<T>::insert", "iterator offset is out of range");
- Q_ASSERT(count >= 0);
- if (count <= 0)
- return m_start + offset;
-
- // Reserve extra space and then copy-on-write.
- reserve(size + count);
- detach();
-
- // Move items up to make room, and replace at the insert point.
- if (QTypeInfo<T>::isStatic) {
- int newcount = count;
- while (newcount > 0) {
- new (m_end++) T();
- --newcount;
- }
- int posn = size;
- while (posn > offset) {
- --posn;
- m_start[posn + count] = m_start[posn];
- }
- while (count > 0) {
- --count;
- m_start[offset + count] = value;
- }
- } else {
- ::memmove(m_start + offset + count, m_start + offset,
- (size - offset) * sizeof(T));
- m_end += count;
- while (count > 0) {
- --count;
- new (m_start + offset + count) T(value);
- }
- }
-
- // Return the new iterator at the insert position.
- return m_start + offset;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE Q_TYPENAME QArray<T, PreallocSize>::iterator QArray<T, PreallocSize>::insert(iterator before, const T &value)
-{
- return insert(before, 1, value);
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::replace(int index, const T &value)
-{
- Q_ASSERT_X(index >= 0 && index < size(),
- "QArray<T>::replace", "index out of range");
- data()[index] = value;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::replace(int index, const T *values, int count)
-{
- if (index < 0 || count <= 0)
- return;
- int replaceSize = index + count;
- if (replaceSize > size())
- resize(replaceSize);
- copyReplace(data() + index, values, count);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::remove(int index)
-{
- remove(index, 1);
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::remove(int index, int count)
-{
- // Truncate the range to be removed.
- int currentSize = size();
- if (index < 0) {
- count += index;
- index = 0;
- }
- if (count > 0 && (index + count) > currentSize)
- count = currentSize - index;
- if (count <= 0)
- return;
-
- // Perform the removal.
- if (index == 0 && count >= currentSize) {
- clear();
- return;
- }
- T *start = data();
- copyReplace(start + index, start + index + count,
- (currentSize - (index + count)));
- resize(currentSize - count);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE Q_TYPENAME QArray<T, PreallocSize>::iterator QArray<T, PreallocSize>::erase(iterator begin, iterator end)
-{
- int index = begin - m_start;
- remove(index, end - begin);
- return m_start + index;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE Q_TYPENAME QArray<T, PreallocSize>::iterator QArray<T, PreallocSize>::erase(iterator pos)
-{
- int index = pos - m_start;
- remove(index, 1);
- return m_start + index;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE int QArray<T, PreallocSize>::indexOf(const T &value, int from) const
-{
- if (from < 0)
- from = qMax(from + size(), 0);
- const T *ptr = m_start + from;
- while (ptr < m_end) {
- if (*ptr == value)
- return ptr - m_start;
- ++ptr;
- }
- return -1;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE int QArray<T, PreallocSize>::lastIndexOf(const T &value, int from) const
-{
- int size = count();
- if (from < 0)
- from += size;
- else if (from >= size)
- from = size - 1;
- if (from >= 0) {
- const T *ptr = m_start + from;
- while (ptr >= m_start) {
- if (*ptr == value)
- return ptr - m_start;
- --ptr;
- }
- }
- return -1;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE bool QArray<T, PreallocSize>::contains(const T &value) const
-{
- const T *ptr = m_start;
- while (ptr < m_end) {
- if (*ptr == value)
- return true;
- ++ptr;
- }
- return false;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE int QArray<T, PreallocSize>::count(const T &value) const
-{
- const T *ptr = m_start;
- int count = 0;
- while (ptr < m_end) {
- if (*ptr == value)
- ++count;
- ++ptr;
- }
- return count;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::resize(int size)
-{
- if (size < 0)
- return;
- int currentSize = count();
- if (size < currentSize) {
- T *start = data(); // Force copy on write if necessary.
- if (QTypeInfo<T>::isComplex)
- free(start + size, currentSize - size);
- m_end = start + size;
- } else if (size > currentSize) {
- grow(size - currentSize);
- while (currentSize++ < size) {
- new (m_end) T();
- ++m_end;
- }
- }
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::reserve(int size)
-{
- int cap = capacity();
- if (size > cap)
- grow(size - this->size());
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::fill(const T &value, int size)
-{
- if (size >= 0)
- resize(size);
- T *ptr = m_start;
- while (ptr < m_end)
- *ptr++ = value;
- return *this;
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::squeeze()
-{
- int size = count();
- if (size <= 0) {
- clear();
- } else if (size < capacity() && m_data) {
- reallocate(size);
- }
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::reverse()
-{
- if (count() > 0) {
- T *src = m_start;
- T *dst = m_end - 1;
- while (src < dst)
- qSwap(*(dst--), *(src++));
- }
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::reversed() const
-{
- QArray<T, PreallocSize> result;
- int count = size();
- if (count > 0) {
- result.extend(count);
- const T *src = m_start;
- T *dst = result.m_end - 1;
- if (!QTypeInfo<T>::isComplex) {
- while (src != m_end)
- *(dst--) = *(src++);
- } else {
- while (src != m_end)
- new (dst--) T(*src++);
- }
- }
- return result;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::mid(int index, int length) const
-{
- int count = size();
- Q_ASSERT(index >= 0 && index <= count);
- if (length < 0 || (index + length) > count)
- length = count - index;
- if (index == 0 && length == count)
- return *this;
- QArray<T, PreallocSize> result;
- result.append(constData() + index, length);
- return result;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::left(int length) const
-{
- return mid(0, length);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::right(int length) const
-{
- int size = count();
- if (length < 0 || length >= size)
- length = size;
- return mid(size - length, length);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE T *QArray<T, PreallocSize>::data()
-{
- detach();
- return m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE const T *QArray<T, PreallocSize>::data() const
-{
- return m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE const T *QArray<T, PreallocSize>::constData() const
-{
- return m_start;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::fromRawData(const T *data, int size)
-{
- Q_ASSERT(size >= 0);
- return QArray<T, PreallocSize>(data, size, false);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> QArray<T, PreallocSize>::fromWritableRawData(T *data, int size)
-{
- Q_ASSERT(size >= 0);
- return QArray<T, PreallocSize>(data, size, true);
-}
-
-template <typename T, int PreallocSize>
-Q_OUTOFLINE_TEMPLATE bool QArray<T, PreallocSize>::operator==
- (const QArray<T, PreallocSize> &other) const
-{
- if (this == &other)
- return true;
- const T *thisData = constData();
- const T *otherData = other.constData();
- if (thisData == otherData)
- return true;
- int thisCount = count();
- int otherCount = other.count();
- if (thisCount == 0 && otherCount == 0)
- return true;
- if (thisCount != otherCount)
- return false;
- for (int index = 0; index < thisCount; ++index, ++thisData, ++otherData)
- if (*thisData != *otherData)
- return false;
- return true;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE bool QArray<T, PreallocSize>::operator!=
- (const QArray<T, PreallocSize> &other) const
-{
- return !(*this == other);
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::operator+=(const T &value)
-{
- append(value);
- return *this;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::operator+=(const QArray<T, PreallocSize> &other)
-{
- append(other);
- return *this;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::operator<<(const T &value)
-{
- append(value);
- return *this;
-}
-
-template <typename T, int PreallocSize>
-Q_INLINE_TEMPLATE QArray<T, PreallocSize> &QArray<T, PreallocSize>::operator<<(const QArray<T, PreallocSize> &other)
-{
- append(other);
- return *this;
-}
-
-#ifndef QT_NO_DATASTREAM
-
-template <typename T, int PreallocSize>
-QDataStream& operator<<(QDataStream& stream, const QArray<T, PreallocSize>& array)
-{
- int size = array.size();
- stream << quint32(size);
- for (int index = 0; index < size; ++index)
- stream << array.at(index);
- return stream;
-}
-
-template <typename T, int PreallocSize>
-QDataStream& operator>>(QDataStream& stream, QArray<T, PreallocSize>& array)
-{
- array.clear();
- quint32 size;
- stream >> size;
- array.reserve(size);
- for (int index = 0; index < int(size); ++index) {
- T t;
- stream >> t;
- array.append(t);
- if (stream.atEnd())
- break;
- }
- return stream;
-}
-
-#endif
-
-#ifndef QT_NO_DEBUG_STREAM
-
-template <typename T, int PreallocSize>
-QDebug operator<<(QDebug dbg, const QArray<T, PreallocSize>& array)
-{
- dbg.nospace() << "QArray(\n";
- int size = array.size();
- for (int index = 0; index < size; ++index) {
- dbg << " " << index << ": " << array.at(index) << "\n";
- }
- dbg << ")\n";
- return dbg.space();
-}
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qcolor4ub.cpp b/src/threed/arrays/qcolor4ub.cpp
deleted file mode 100644
index a27193cb..00000000
--- a/src/threed/arrays/qcolor4ub.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qcolor4ub.h"
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QColor4ub
- \brief The QColor4ub class represents a color by four unsigned byte components.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- OpenGL applications commonly use four unsigned byte values to compactly
- represent a color value. QColor4ub provides a convenience
- class for manipulating such compact color values.
-
- An alternative is to represent a color value as four floating-point
- values between 0.0 and 1.0. The QVector4D class can be used for
- that purpose if required.
-*/
-
-/*!
- \fn QColor4ub::QColor4ub()
-
- Constructs a four-byte default color value of (0, 0, 0, 255).
-*/
-
-/*!
- \fn QColor4ub::QColor4ub(int red, int green, int blue, int alpha)
-
- Constructs a four-byte color value with the components \a red,
- \a green, \a blue, and \a alpha.
-*/
-
-/*!
- \fn QColor4ub::QColor4ub(const QColor& color)
-
- Constructs a four-byte color value from \a color.
-*/
-
-/*!
- \fn QColor4ub::QColor4ub(Qt::GlobalColor color)
-
- Constructs a four-byte color value from \a color.
-*/
-
-/*!
- \fn QColor4ub::QColor4ub(QRgb rgba)
-
- Constructs a four-byte color value from the red, green, blue, and
- alpha components of \a rgba.
-*/
-
-/*!
- \fn QColor4ub& QColor4ub::operator=(const QColor& color)
-
- Copies the red, green, blue, and alpha components of \a color
- into this object.
-*/
-
-/*!
- \fn QColor4ub& QColor4ub::operator=(Qt::GlobalColor color)
-
- Copies the red, green, blue, and alpha components of the
- specified global \a color name into this object.
-*/
-
-/*!
- \fn int QColor4ub::red() const
-
- Returns the red component of this color, between 0 and 255.
-
- \sa green(), blue(), alpha(), setRed(), redF()
-*/
-
-/*!
- \fn int QColor4ub::green() const
-
- Returns the green component of this color, between 0 and 255.
-
- \sa red(), blue(), alpha(), setGreen(), greenF()
-*/
-
-/*!
- \fn int QColor4ub::blue() const
-
- Returns the blue component of this color, between 0 and 255.
-
- \sa red(), green(), alpha(), setBlue(), blueF()
-*/
-
-/*!
- \fn int QColor4ub::alpha() const
-
- Returns the alpha component of this color, between 0 and 255.
-
- \sa red(), green(), blue(), setAlpha(), alphaF()
-*/
-
-/*!
- \fn void QColor4ub::setRed(int value)
-
- Sets the red component of this color to \a value, between 0 and 255.
-
- \sa setGreen(), setBlue(), setAlpha(), red(), setRedF()
-*/
-
-/*!
- \fn void QColor4ub::setGreen(int value)
-
- Sets the green component of this color to \a value, between 0 and 255.
-
- \sa setRed(), setBlue(), setAlpha(), green(), setGreenF()
-*/
-
-/*!
- \fn void QColor4ub::setBlue(int value)
-
- Sets the blue component of this color to \a value, between 0 and 255.
-
- \sa setRed(), setGreen(), setAlpha(), blue(), setBlueF()
-*/
-
-/*!
- \fn void QColor4ub::setAlpha(int value)
-
- Sets the alpha component of this color to \a value, between 0 and 255.
-
- \sa setRed(), setGreen(), setBlue(), alpha(), setAlphaF()
-*/
-
-/*!
- \fn qreal QColor4ub::redF() const { return m_red / 255.0f; }
-
- Returns the red component of this color as a floating-point
- value between 0 and 1.
-
- \sa greenF(), blueF(), alphaF(), setRedF(), red()
-*/
-
-/*!
- \fn qreal QColor4ub::greenF() const { return m_green / 255.0f; }
-
- Returns the green component of this color as a floating-point
- value between 0 and 1.
-
- \sa redF(), blueF(), alphaF(), setGreenF(), green()
-*/
-
-/*!
- \fn qreal QColor4ub::blueF() const { return m_blue / 255.0f; }
-
- Returns the blue component of this color as a floating-point
- value between 0 and 1.
-
- \sa redF(), greenF(), alphaF(), setBlueF(), blue()
-*/
-
-/*!
- \fn qreal QColor4ub::alphaF() const { return m_alpha / 255.0f; }
-
- Returns the alpha component of this color as a floating-point
- value between 0 and 1.
-
- \sa redF(), greenF(), blueF(), setAlphaF(), alpha()
-*/
-
-/*!
- \fn void QColor4ub::setRedF(qreal value)
-
- Sets the red component of this color to a floating-point \a value,
- between 0 and 1.
-
- \sa setGreenF(), setBlueF(), setAlphaF(), redF(), setRed()
-*/
-
-/*!
- \fn void QColor4ub::setGreenF(qreal value)
-
- Sets the green component of this color to a floating-point \a value,
- between 0 and 1.
-
- \sa setRedF(), setBlueF(), setAlphaF(), greenF(), setGreen()
-*/
-
-/*!
- \fn void QColor4ub::setBlueF(qreal value)
-
- Sets the blue component of this color to a floating-point \a value,
- between 0 and 1.
-
- \sa setRedF(), setGreenF(), setAlphaF(), blueF(), setBlue()
-*/
-
-/*!
- \fn void QColor4ub::setAlphaF(qreal value)
-
- Sets the alpha component of this color to a floating-point \a value,
- between 0 and 1.
-
- \sa setRedF(), setGreenF(), setBlueF(), alphaF(), setAlpha()
-*/
-
-/*!
- \fn void QColor4ub::setRgb(int red, int green, int blue, int alpha)
-
- Sets the components of this color to \a red, \a green, \a blue,
- and \a alpha. Each component is between 0 and 255.
-
- \sa setRgbF(), fromRgb()
-*/
-
-/*!
- \fn void QColor4ub::setRgbF(qreal red, qreal green, qreal blue, qreal alpha)
-
- Sets the components of this color to \a red, \a green, \a blue,
- and \a alpha. Each component is a floating-point value between 0 and 1.
-
- \sa setRgb(), fromRgbF()
-*/
-
-/*!
- \fn QColor4ub QColor4ub::fromRgb(int red, int green, int blue, int alpha)
-
- Returns a QColor4ub with the components \a red, \a green, \a blue,
- and \a alpha. Each component is between 0 and 255.
-
- \sa fromRgbF(), setRgb()
-*/
-
-/*!
- \fn QColor4ub QColor4ub::fromRgbF(qreal red, qreal green, qreal blue, qreal alpha)
-
- Returns a QColor4ub with the components \a red, \a green, \a blue,
- and \a alpha. Each component is a floating-point value between 0 and 1.
-
- \sa fromRgb(), setRgbF()
-*/
-
-/*!
- \fn QColor4ub QColor4ub::fromRaw(const uchar *data)
-
- Returns a QColor4ub with components from the first four elements
- in \a data. The \a data parameter must contain at least four
- elements and not be null.
-*/
-
-/*!
- \fn QColor QColor4ub::toColor() const
-
- Returns this color as a QColor.
-*/
-
-/*!
- \fn bool QColor4ub::operator==(const QColor4ub& other) const
-
- Returns true if this color is the same as \a other; false otherwise.
-*/
-
-/*!
- \fn bool QColor4ub::operator!=(const QColor4ub& other) const
-
- Returns true if this color is not the same as \a other; false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QColor4ub &color)
-{
- dbg.nospace() << "QColor4ub("
- << color.redF() << ", " << color.greenF() << ", "
- << color.blueF() << ", " << color.alphaF() << ')';
- return dbg.space();
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qcolor4ub.h b/src/threed/arrays/qcolor4ub.h
deleted file mode 100644
index f306e6ab..00000000
--- a/src/threed/arrays/qcolor4ub.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QCOLOR4UB_H
-#define QCOLOR4UB_H
-
-#include "qt3dglobal.h"
-#include <QtGui/qcolor.h>
-#include <QtCore/qmetatype.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QColor4ub
-{
-public:
- QColor4ub();
- QColor4ub(int red, int green, int blue, int alpha = 255);
- QColor4ub(const QColor& color);
- QColor4ub(Qt::GlobalColor color);
- QColor4ub(QRgb rgba);
-
- QColor4ub& operator=(const QColor& color);
- QColor4ub& operator=(Qt::GlobalColor color);
-
- int red() const { return m_red; }
- int green() const { return m_green; }
- int blue() const { return m_blue; }
- int alpha() const { return m_alpha; }
-
- void setRed(int value) { m_red = uchar(value); }
- void setGreen(int value) { m_green = uchar(value); }
- void setBlue(int value) { m_blue = uchar(value); }
- void setAlpha(int value) { m_alpha = uchar(value); }
-
- qreal redF() const { return m_red / 255.0f; }
- qreal greenF() const { return m_green / 255.0f; }
- qreal blueF() const { return m_blue / 255.0f; }
- qreal alphaF() const { return m_alpha / 255.0f; }
-
- void setRedF(qreal value) { m_red = uchar(qRound(value * 255.0f)); }
- void setGreenF(qreal value) { m_green = uchar(qRound(value * 255.0f)); }
- void setBlueF(qreal value) { m_blue = uchar(qRound(value * 255.0f)); }
- void setAlphaF(qreal value) { m_alpha = uchar(qRound(value * 255.0f)); }
-
- void setRgb(int red, int green, int blue, int alpha = 255);
- void setRgbF(qreal red, qreal green, qreal blue, qreal alpha = 1.0f);
-
- static QColor4ub fromRgb(int red, int green, int blue, int alpha = 255);
- static QColor4ub fromRgbF
- (qreal red, qreal green, qreal blue, qreal alpha = 1.0f);
- static QColor4ub fromRaw(const uchar *data);
-
- QColor toColor() const;
-
- bool operator==(const QColor4ub& other) const;
- bool operator!=(const QColor4ub& other) const;
-
-private:
- QColor4ub(const uchar *data);
-
- uchar m_red;
- uchar m_green;
- uchar m_blue;
- uchar m_alpha;
-};
-
-inline QColor4ub::QColor4ub() : m_red(0), m_green(0), m_blue(0), m_alpha(255) {}
-
-inline QColor4ub::QColor4ub(int red, int green, int blue, int alpha)
- : m_red(uchar(red)), m_green(uchar(green)),
- m_blue(uchar(blue)), m_alpha(uchar(alpha)) {}
-
-inline QColor4ub::QColor4ub(const QColor& color)
- : m_red(uchar(color.red())), m_green(uchar(color.green())),
- m_blue(uchar(color.blue())), m_alpha(uchar(color.alpha())) {}
-
-inline QColor4ub::QColor4ub(Qt::GlobalColor color)
-{
- QColor c(color);
- m_red = uchar(c.red());
- m_green = uchar(c.green());
- m_blue = uchar(c.blue());
- m_alpha = uchar(c.alpha());
-}
-
-inline QColor4ub::QColor4ub(QRgb rgba)
- : m_red(uchar(qRed(rgba))), m_green(uchar(qGreen(rgba))),
- m_blue(uchar(qBlue(rgba))), m_alpha(uchar(qAlpha(rgba))) {}
-
-inline QColor4ub::QColor4ub(const uchar *data)
- : m_red(data[0]), m_green(data[1]), m_blue(data[2]), m_alpha(data[3]) {}
-
-inline QColor4ub& QColor4ub::operator=(const QColor& color)
-{
- m_red = uchar(color.red());
- m_green = uchar(color.green());
- m_blue = uchar(color.blue());
- m_alpha = uchar(color.alpha());
- return *this;
-}
-
-inline QColor4ub& QColor4ub::operator=(Qt::GlobalColor color)
-{
- QColor c(color);
- m_red = uchar(c.red());
- m_green = uchar(c.green());
- m_blue = uchar(c.blue());
- m_alpha = uchar(c.alpha());
- return *this;
-}
-
-inline void QColor4ub::setRgb(int red, int green, int blue, int alpha)
-{
- m_red = uchar(red);
- m_green = uchar(green);
- m_blue = uchar(blue);
- m_alpha = uchar(alpha);
-}
-
-inline void QColor4ub::setRgbF(qreal red, qreal green, qreal blue, qreal alpha)
-{
- m_red = uchar(qRound(red * 255.0f));
- m_green = uchar(qRound(green * 255.0f));
- m_blue = uchar(qRound(blue * 255.0f));
- m_alpha = uchar(qRound(alpha * 255.0f));
-}
-
-inline QColor4ub QColor4ub::fromRgb(int red, int green, int blue, int alpha)
-{
- return QColor4ub(red, green, blue, alpha);
-}
-
-inline QColor4ub QColor4ub::fromRgbF
- (qreal red, qreal green, qreal blue, qreal alpha)
-{
- return QColor4ub(qRound(red * 255.0f), qRound(green * 255.0f),
- qRound(blue * 255.0f), qRound(alpha * 255.0f));
-}
-
-inline QColor4ub QColor4ub::fromRaw(const uchar *data)
-{
- return QColor4ub(data);
-}
-
-inline QColor QColor4ub::toColor() const
-{
- return QColor(m_red, m_green, m_blue, m_alpha);
-}
-
-inline bool QColor4ub::operator==(const QColor4ub& other) const
-{
- return m_red == other.m_red && m_green == other.m_green &&
- m_blue == other.m_blue && m_alpha == other.m_alpha;
-}
-
-inline bool QColor4ub::operator!=(const QColor4ub& other) const
-{
- return m_red != other.m_red || m_green != other.m_green ||
- m_blue != other.m_blue || m_alpha != other.m_alpha;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QColor4ub &color);
-#endif
-
-Q_DECLARE_TYPEINFO(QColor4ub, Q_MOVABLE_TYPE);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QColor4ub)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qcustomdataarray.cpp b/src/threed/arrays/qcustomdataarray.cpp
deleted file mode 100644
index aaacfe98..00000000
--- a/src/threed/arrays/qcustomdataarray.cpp
+++ /dev/null
@@ -1,909 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qcustomdataarray.h"
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QCustomDataArray
- \brief The QCustomDataArray class is a polymorphic array of data values suitable for use in 3D applications.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QArray is an efficient storage mechanism for vertex attributes.
- However, there are some situations where the element type of a custom
- vertex attribute is not known until runtime. QCustomDataArray is
- intended for use in those situations. It has a small performance
- penalty compared to QArray to achieve polymorphism.
-
- The elements that may be stored in a QCustomDataArray are limited
- to a few types: float, QVector2D, QVector3D, QVector4D, and
- QColor4ub. This provides a reasonable range of efficient use
- cases without overloading the API. QArray can be used on
- any type, but is restricted to types that are known at compile time.
-
- Like QArray, QCustomDataArray uses implicit sharing and
- copy-on-write semantics to support passing large arrays around
- an application with little overhead.
-
- \sa QArray
-*/
-
-/*!
- \enum QCustomDataArray::ElementType
- This enum defines the element type within a QCustomDataArray.
-
- \value Float The elements are of type float.
- \value Vector2D The elements are of type QVector2D.
- \value Vector3D The elements are of type QVector3D.
- \value Vector4D The elements are of type QVector4D.
- \value Color The elements are of type QColor4ub, which consists of
- four unsigned bytes. To represent colors as four floating-point
- values, use Vector4D as the element type.
-*/
-
-/*!
- \fn QCustomDataArray::QCustomDataArray()
-
- Constructs an empty custom data array. The elementType() will
- initially be QCustomDataArray::Float, which can be changed with a
- call to setElementType() before the elements are appended.
-
- \sa setElementType(), append()
-*/
-
-/*!
- Constructs an empty custom data array with elements represented
- by the specified \a type.
-
- \sa setElementType()
-*/
-QCustomDataArray::QCustomDataArray(QCustomDataArray::ElementType type)
-{
- setElementType(type);
-}
-
-/*!
- Constructs an empty custom data array with elements represented
- by the specified \a type. The array is initially resized to \a size;
- filling all elements with zeroes.
-
- \sa setElementType(), resize()
-*/
-QCustomDataArray::QCustomDataArray(QCustomDataArray::ElementType type, int size)
-{
- setElementType(type);
- resize(size);
-}
-
-/*!
- \fn QCustomDataArray::QCustomDataArray(const QCustomDataArray& other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- Constructs a copy of the floating-point QArray \a other.
-
- The elementType() will be set to QCustomDataArray::Float.
-
- \sa toFloatArray()
-*/
-QCustomDataArray::QCustomDataArray(const QArray<float>& other)
- : m_array(other),
- m_elementType(QCustomDataArray::Float),
- m_elementComponents(1)
-{
-}
-
-/*!
- Constructs a copy of the 2D vector QArray \a other.
-
- The elementType() will be set to QCustomDataArray::Vector2D.
-
- This constructor needs to make a complete copy of the data
- in \a other so it may be expensive performance-wise.
-
- \sa toVector2DArray()
-*/
-QCustomDataArray::QCustomDataArray(const QArray<QVector2D>& other)
- : m_elementType(QCustomDataArray::Vector2D),
- m_elementComponents(2)
-{
- int size = other.size();
- if (size > 0) {
- const QVector2D *src = other.constData();
- float *dst = m_array.extend(size * 2);
- qMemCopy(dst, src, size * sizeof(QVector2D));
- }
-}
-
-/*!
- Constructs a copy of the 3D vector QArray \a other.
-
- The elementType() will be set to QCustomDataArray::Vector3D.
-
- This constructor needs to make a complete copy of the data
- in \a other so it may be expensive performance-wise.
-
- \sa toVector3DArray()
-*/
-QCustomDataArray::QCustomDataArray(const QArray<QVector3D>& other)
- : m_elementType(QCustomDataArray::Vector3D),
- m_elementComponents(3)
-{
- int size = other.size();
- if (size > 0) {
- const QVector3D *src = other.constData();
- float *dst = m_array.extend(size * 3);
- qMemCopy(dst, src, size * sizeof(QVector3D));
- }
-}
-
-/*!
- Constructs a copy of the 4D vector QArray \a other.
-
- The elementType() will be set to QCustomDataArray::Vector4D.
-
- This constructor needs to make a complete copy of the data
- in \a other so it may be expensive performance-wise.
-
- \sa toVector3DArray()
-*/
-QCustomDataArray::QCustomDataArray(const QArray<QVector4D>& other)
- : m_elementType(QCustomDataArray::Vector4D),
- m_elementComponents(4)
-{
- int size = other.size();
- if (size > 0) {
- const QVector4D *src = other.constData();
- float *dst = m_array.extend(size * 4);
- qMemCopy(dst, src, size * sizeof(QVector4D));
- }
-}
-
-/*!
- Constructs a copy of the color QArray \a other.
-
- The elementType() will be set to QCustomDataArray::Color.
-
- This constructor needs to make a complete copy of the data
- in \a other so it may be expensive performance-wise.
-
- \sa toColorArray()
-*/
-QCustomDataArray::QCustomDataArray(const QArray<QColor4ub>& other)
- : m_elementType(QCustomDataArray::Color),
- m_elementComponents(1)
-{
- int size = other.size();
- qMemCopy(m_array.extend(size), other.constData(), sizeof(QColor4ub) * size);
-}
-
-/*!
- \fn QCustomDataArray::~QCustomDataArray()
-
- Destroys this custom data array.
-*/
-
-/*!
- \fn QCustomDataArray& QCustomDataArray::operator=(const QCustomDataArray& other)
-
- Assigns \a other to this custom data array and returns a reference
- to this custom data array.
-
- The previous elementType() for this custom data array will be
- replaced with the type from \a other. The element data is assigned
- directly without conversion.
-*/
-
-/*!
- \fn QCustomDataArray::ElementType QCustomDataArray::elementType() const
-
- Returns the representation type of elements in this custom data array.
-
- \sa setElementType()
-*/
-
-/*!
- Sets the representation \a type of elements in this custom data array.
- The array must be empty to change the element type.
-
- \sa elementType(), append()
-*/
-void QCustomDataArray::setElementType(QCustomDataArray::ElementType type)
-{
- Q_ASSERT(m_array.isEmpty());
- m_elementType = type;
- switch (type) {
- case QCustomDataArray::Float:
- m_elementComponents = 1;
- break;
- case QCustomDataArray::Vector2D:
- m_elementComponents = 2;
- break;
- case QCustomDataArray::Vector3D:
- m_elementComponents = 3;
- break;
- case QCustomDataArray::Vector4D:
- m_elementComponents = 4;
- break;
- case QCustomDataArray::Color:
- m_elementComponents = 1; // 4 bytes packed into a float.
- break;
- default:
- Q_ASSERT_X(false, "QCustomDataArray::setElementType",
- "unknown element type");
- m_elementComponents = 1;
- break;
- }
-}
-
-/*!
- \fn int QCustomDataArray::size() const
-
- Returns the number of elements in this custom data array.
-
- \sa resize(), capacity(), isEmpty()
-*/
-
-/*!
- \fn int QCustomDataArray::count() const
-
- Same as size(); provided for convenience.
-*/
-
-/*!
- \fn int QCustomDataArray::capacity() const
-
- Returns the number of elements that can be stored in this
- custom data array before reallocation.
-
- \sa reserve(), size()
-*/
-
-/*!
- \fn bool QCustomDataArray::isEmpty() const
-
- Returns true if this data array is empty; false otherwise.
-
- \sa size(), clear()
-*/
-
-/*!
- \fn int QCustomDataArray::elementSize() const
-
- Returns the size of individual elements in this custom data
- array, in bytes. For example, the element size of an array
- containing QVector3D values will be 3 * sizeof(float),
- normally 12.
-
- \sa setElementType()
-*/
-
-/*!
- \fn void QCustomDataArray::clear()
-
- Clears all elements from this custom data array and sets the size to zero.
-
- This function will deallocate any memory that is used on the heap
- to store the custom data array's elements. To reuse the same memory
- as before, call resize() with an argument of zero.
-
- \sa resize(), isEmpty()
-*/
-
-/*!
- \fn void QCustomDataArray::resize(int size)
-
- Sets the size of the custom data array to \a size. If \a size is greater
- than the current size, elements are added to the end; the new elements
- are initialized with all-zeroes. If \a size is less than the current
- size, elements are removed from the end.
-
- \sa size(), reserve(), squeeze()
-*/
-
-/*!
- \fn void QCustomDataArray::reserve(int size)
-
- Increases the capacity of this custom data array to reserve space for
- at least \a size elements. If the capacity is already larger
- than \a size, this function does nothing; in particular, it does
- not remove elements from the array like resize() does.
-
- This function can be useful when you know how roughly many elements
- will be appended ahead of time. Reserving the space once can avoid
- unnecessary realloc operations later.
-
- \sa capacity(), resize(), squeeze()
-*/
-
-/*!
- \fn void QCustomDataArray::squeeze()
-
- Releases any memory not required to store the custom data array's
- elements by reducing its capacity() to size().
-
- This function is intended for reclaiming memory in a custom data
- array that is being used over and over with different contents.
- As elements are added to a custom data array, it will be constantly
- expanded in size. This function can realloc the custom data array
- to a smaller size to reclaim unused memory.
-
- \sa reserve(), capacity()
-*/
-
-/*!
- Returns the value of the element at \a index in this custom
- data array as a QVariant.
-
- Color elements are returned as a QVariant containing a
- QColor4ub, not a QColor.
-
- \sa setAt(), append(), floatAt(), vector2DAt(), vector3DAt()
- \sa vector4DAt(), colorAt()
-*/
-QVariant QCustomDataArray::at(int index) const
-{
- Q_ASSERT(index >= 0 && index < size());
-
- const float *data;
- switch (m_elementType) {
-
- case QCustomDataArray::Float:
- return QVariant(m_array.at(index));
-
- case QCustomDataArray::Vector2D:
- data = m_array.constData() + index * 2;
- return qVariantFromValue(QVector2D(data[0], data[1]));
-
- case QCustomDataArray::Vector3D:
- data = m_array.constData() + index * 3;
- return qVariantFromValue(QVector3D(data[0], data[1], data[2]));
-
- case QCustomDataArray::Vector4D:
- data = m_array.constData() + index * 4;
- return qVariantFromValue
- (QVector4D(data[0], data[1], data[2], data[3]));
-
- case QCustomDataArray::Color:
- data = m_array.constData() + index;
- return qVariantFromValue
- (QColor4ub::fromRaw(reinterpret_cast<const uchar *>(data)));
-
- default: break;
- }
- return QVariant();
-}
-
-/*!
- Sets the element at \a index in this custom data array to \a value.
-
- The type of \a value must be consistent with elementType().
- The two exceptions to this are that a Float value can be
- specified by either a float or double QVariant, and a Color
- value can be specified as either a QColor4ub or QColor QVariant.
-
- \sa at(), elementType()
-*/
-void QCustomDataArray::setAt(int index, const QVariant& value)
-{
- Q_ASSERT(index >= 0 && index < size());
-
- switch (value.type()) {
-
- case (QVariant::Type)QMetaType::Float:
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- m_array[index] = value.toFloat();
- break;
-
- case QVariant::Double:
- // Convert Double into Float.
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- m_array[index] = float(value.toDouble());
- break;
-
- case QVariant::Vector2D:
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- *(reinterpret_cast<QVector2D *>(m_array.data() + index * 2))
- = qVariantValue<QVector2D>(value);
- break;
-
- case QVariant::Vector3D:
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- *(reinterpret_cast<QVector3D *>(m_array.data() + index * 3))
- = qVariantValue<QVector3D>(value);
- break;
-
- case QVariant::Vector4D:
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- *(reinterpret_cast<QVector4D *>(m_array.data() + index * 4))
- = qVariantValue<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));
- 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);
- break;
- }
- // Fall through.
-
- default:
- Q_ASSERT_X(false, "QCustomDataArray::setAt",
- "QVariant type not supported for elements");
- break;
- }
-}
-
-/*!
- \fn void QCustomDataArray::setAt(int index, qreal x)
- \overload
-
- Sets the floating-point element at \a index in this custom data
- array to \a x. The elementType() must be QCustomDataArray::Float.
-
- \sa at(), elementType(), floatAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, qreal x, qreal y)
- \overload
-
- Sets the 2D vector element at \a index in this custom
- data array to (\a x, \a y). The elementType() must be
- QCustomDataArray::Vector2D.
-
- \sa at(), elementType(), vector2DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z)
- \overload
-
- Sets the 3D vector element at \a index in this custom
- data array to (\a x, \a y, \a z). The elementType() must be
- QCustomDataArray::Vector3D.
-
- \sa at(), elementType(), vector3DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z, qreal w)
- \overload
-
- Sets the 4D vector element at \a index in this custom
- data array to (\a x, \a y, \a z, \a w). The elementType() must be
- QCustomDataArray::Vector4D.
-
- \sa at(), elementType(), vector4DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, const QVector2D& value)
- \overload
-
- Sets the 2D vector element at \a index in this custom
- data array to \a value. The elementType() must be
- QCustomDataArray::Vector2D.
-
- \sa at(), elementType(), vector2DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, const QVector3D& value)
- \overload
-
- Sets the 3D vector element at \a index in this custom
- data array to \a value. The elementType() must be
- QCustomDataArray::Vector3D.
-
- \sa at(), elementType(), vector3DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, const QVector4D& value)
- \overload
-
- Sets the 4D vector element at \a index in this custom
- data array to \a value. The elementType() must be
- QCustomDataArray::Vector4D.
-
- \sa at(), elementType(), vector4DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, const QColor4ub& value)
- \overload
-
- Sets the color element at \a index in this custom data array to \a value.
- The elementType() must be QCustomDataArray::Color.
-
- \sa at(), elementType(), colorAt()
-*/
-
-/*!
- \fn void QCustomDataArray::setAt(int index, Qt::GlobalColor value)
- \overload
-
- Sets the color element at \a index in this custom data array to \a value.
- The elementType() must be QCustomDataArray::Color.
-
- \sa at(), elementType(), colorAt()
-*/
-
-/*!
- \fn qreal QCustomDataArray::floatAt(int index) const
-
- Returns the floating-point element at \a index in this custom data array.
- The elementType() must be QCustomDataArray::Float.
-
- \sa at(), setAt(), elementType()
-*/
-
-/*!
- \fn QVector2D QCustomDataArray::vector2DAt(int index) const
-
- Returns the 2D vector element at \a index in this custom data array.
- The elementType() must be QCustomDataArray::Vector2D.
-
- \sa at(), setAt(), elementType()
-*/
-
-/*!
- \fn QVector3D QCustomDataArray::vector3DAt(int index) const
-
- Returns the 3D vector element at \a index in this custom data array.
- The elementType() must be QCustomDataArray::Vector3D.
-
- \sa at(), setAt(), elementType()
-*/
-
-/*!
- \fn QVector4D QCustomDataArray::vector4DAt(int index) const
-
- Returns the 4D vector element at \a index in this custom data array.
- The elementType() must be QCustomDataArray::Vector4D.
-
- \sa at(), setAt(), elementType()
-*/
-
-/*!
- \fn QColor4ub QCustomDataArray::colorAt(int index) const
-
- Returns the color element at \a index in this custom data array.
- The elementType() must be QCustomDataArray::Color.
-
- \sa at(), setAt(), elementType()
-*/
-
-/*!
- \fn void QCustomDataArray::append(qreal x)
- \overload
-
- Appends the floating-point value \a x to this custom data array.
- The elementType() must be QCustomDataArray::Float.
-
- \sa setAt(), floatAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(qreal x, qreal y)
- \overload
-
- Appends the 2D vector value (\a x, \a y) to this custom data array.
- The elementType() must be QCustomDataArray::Vector2D.
-
- \sa setAt(), vector2DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(qreal x, qreal y, qreal z)
- \overload
-
- Appends the 3D vector value (\a x, \a y, \a z) to this custom
- data array. The elementType() must be QCustomDataArray::Vector3D.
-
- \sa setAt(), vector3DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(qreal x, qreal y, qreal z, qreal w)
- \overload
-
- Appends the 4D vector value (\a x, \a y, \a z, \a w) to this custom
- data array. The elementType() must be QCustomDataArray::Vector4D.
-
- \sa setAt(), vector4DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(const QVector2D& value)
- \overload
-
- Appends the 2D vector \a value to this custom data array.
- The elementType() must be QCustomDataArray::Vector2D.
-
- \sa setAt(), vector2DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(const QVector3D& value)
- \overload
-
- Appends the 3D vector \a value to this custom data array.
- The elementType() must be QCustomDataArray::Vector3D.
-
- \sa setAt(), vector3DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(const QVector4D& value)
- \overload
-
- Appends the 4D vector \a value to this custom data array.
- The elementType() must be QCustomDataArray::Vector4D.
-
- \sa setAt(), vector4DAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(const QColor4ub& value)
- \overload
-
- Appends the color \a value to this custom data array.
- The elementType() must be QCustomDataArray::Color.
-
- \sa setAt(), colorAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(Qt::GlobalColor value)
- \overload
-
- Appends the color \a value to this custom data array.
- The elementType() must be QCustomDataArray::Color.
-
- \sa setAt(), colorAt()
-*/
-
-/*!
- \fn void QCustomDataArray::append(const QCustomDataArray &array)
- \overload
-
- Appends the values in \a array to this custom data array. This
- custom data array must have the same element type as \a array,
- unless this custom data array is empty - in which case the
- element type and data of \a array will be assigned to this.
-*/
-
-/*!
- Appends \a value to this custom data array.
-
- The type of \a value must be consistent with elementType().
- The two exceptions to this are that a Float value can be
- specified by either a float or double QVariant, and a Color
- value can be specified as either a QColor4ub or QColor QVariant.
-
- \sa at(), setAt(), elementType()
-*/
-void QCustomDataArray::append(const QVariant& value)
-{
- switch (value.type()) {
-
- case (QVariant::Type)QMetaType::Float:
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- m_array.append(value.toFloat());
- break;
-
- case QVariant::Double:
- // Convert Double into Float.
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- m_array.append(float(value.toDouble()));
- break;
-
- case QVariant::Vector2D:
- append(qVariantValue<QVector2D>(value));
- break;
-
- case QVariant::Vector3D:
- append(qVariantValue<QVector3D>(value));
- break;
-
- case QVariant::Vector4D:
- append(qVariantValue<QVector4D>(value));
- break;
-
- case QVariant::Color:
- // Convert QColor into QColor4ub.
- append(QColor4ub(qVariantValue<QColor>(value)));
- break;
-
- case QVariant::UserType:
- if (value.userType() == qMetaTypeId<QColor4ub>()) {
- append(qVariantValue<QColor4ub>(value));
- break;
- }
- // Fall through.
-
- default:
- Q_ASSERT_X(false, "QCustomDataArray::append",
- "QVariant type not supported for elements");
- break;
- }
-}
-
-/*!
- Returns the contents of this custom data array as a QArray
- of float values.
-
- The elementType() must be QCustomDataArray::Float.
-*/
-QArray<float> QCustomDataArray::toFloatArray() const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- return m_array;
-}
-
-/*!
- Returns the contents of this custom data array as a QArray
- of QVector2D values.
-
- The elementType() must be QCustomDataArray::Vector2D.
-
- This function needs to make a complete copy of the data
- in this array so it may be expensive performance-wise.
-*/
-QArray<QVector2D> QCustomDataArray::toVector2DArray() const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- int size = m_array.size() / 2;
- QArray<QVector2D> result;
- if (size > 0) {
- QVector2D *dst = result.extend(size);
- const float *src = m_array.constData();
- qMemCopy(dst, src, size * sizeof(QVector2D));
- }
- return result;
-}
-
-/*!
- Returns the contents of this custom data array as a QArray
- of QVector3D values.
-
- The elementType() must be QCustomDataArray::Vector3D.
-
- This function needs to make a complete copy of the data
- in this array so it may be expensive performance-wise.
-*/
-QArray<QVector3D> QCustomDataArray::toVector3DArray() const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- int size = m_array.size() / 3;
- QArray<QVector3D> result;
- if (size > 0) {
- QVector3D *dst = result.extend(size);
- const float *src = m_array.constData();
- qMemCopy(dst, src, size * sizeof(QVector3D));
- }
- return result;
-}
-
-/*!
- Returns the contents of this custom data array as a QArray
- of QVector4D values.
-
- The elementType() must be QCustomDataArray::Vector4D.
-
- This function needs to make a complete copy of the data
- in this array so it may be expensive performance-wise.
-*/
-QArray<QVector4D> QCustomDataArray::toVector4DArray() const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- int size = m_array.size() / 4;
- QArray<QVector4D> result;
- if (size > 0) {
- QVector4D *dst = result.extend(size);
- const float *src = m_array.constData();
- qMemCopy(dst, src, size * sizeof(QVector4D));
- }
- return result;
-}
-
-/*!
- Returns the contents of this custom data array as a QArray
- of QColor4ub values.
-
- The elementType() must be QCustomDataArray::Color.
-
- This function needs to make a complete copy of the data
- in this array so it may be expensive performance-wise.
-*/
-QArray<QColor4ub> QCustomDataArray::toColorArray() const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- int size = m_array.size();
- QArray<QColor4ub> result;
- result.reserve(size);
- const QColor4ub *data =
- reinterpret_cast<const QColor4ub *>(m_array.constData());
- for (int index = 0; index < size; ++index)
- result.append(*data++);
- return result;
-}
-
-/*!
- \fn const void *QCustomDataArray::data() const
-
- Returns a const pointer to the data stored in the custom data array.
- The pointer can be used to access the items in the custom data array.
- The pointer remains valid as long as the custom data array isn't
- reallocated.
-
- This function is mostly useful to pass a custom data array to a function
- that accepts a plain C++ array.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QCustomDataArray &array)
-{
- dbg << "QCustomDataArray" << &array << " -- count:" << array.count();
- for (int i = 0; i < array.count(); ++i)
- dbg << array.at(i);
- return dbg;
-}
-#endif
-
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qcustomdataarray.h b/src/threed/arrays/qcustomdataarray.h
deleted file mode 100644
index 5a05ba15..00000000
--- a/src/threed/arrays/qcustomdataarray.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QCUSTOMDATAARRAY_H
-#define QCUSTOMDATAARRAY_H
-
-#include "qarray.h"
-#include "qcolor4ub.h"
-#include <QtCore/qvariant.h>
-#include <QtGui/qvector2d.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLVertexBundleCustomAttribute;
-class QGeometryData;
-
-class Q_QT3D_EXPORT QCustomDataArray
-{
-public:
- enum ElementType
- {
- Float,
- Vector2D,
- Vector3D,
- Vector4D,
- Color
- };
-
- QCustomDataArray();
- explicit QCustomDataArray(QCustomDataArray::ElementType type);
- QCustomDataArray(QCustomDataArray::ElementType type, int size);
- QCustomDataArray(const QCustomDataArray& other);
- QCustomDataArray(const QArray<float>& other);
- QCustomDataArray(const QArray<QVector2D>& other);
- QCustomDataArray(const QArray<QVector3D>& other);
- QCustomDataArray(const QArray<QVector4D>& other);
- QCustomDataArray(const QArray<QColor4ub>& other);
- ~QCustomDataArray();
-
- QCustomDataArray& operator=(const QCustomDataArray& other);
-
- QCustomDataArray::ElementType elementType() const;
- void setElementType(QCustomDataArray::ElementType type);
-
- int size() const;
- int count() const;
-
- int capacity() const;
- bool isEmpty() const;
-
- int elementSize() const;
-
- void clear();
- void reserve(int size);
- void resize(int size);
- void squeeze();
-
- QVariant at(int index) const;
- void setAt(int index, const QVariant& value);
-
- void setAt(int index, qreal x);
- void setAt(int index, qreal x, qreal y);
- void setAt(int index, qreal x, qreal y, qreal z);
- void setAt(int index, qreal x, qreal y, qreal z, qreal w);
- void setAt(int index, const QVector2D& value);
- void setAt(int index, const QVector3D& value);
- void setAt(int index, const QVector4D& value);
- void setAt(int index, const QColor4ub& value);
- void setAt(int index, Qt::GlobalColor value);
-
- qreal floatAt(int index) const;
- QVector2D vector2DAt(int index) const;
- QVector3D vector3DAt(int index) const;
- QVector4D vector4DAt(int index) const;
- QColor4ub colorAt(int index) const;
-
- void append(qreal x);
- void append(qreal x, qreal y);
- void append(qreal x, qreal y, qreal z);
- void append(qreal x, qreal y, qreal z, qreal w);
- void append(const QVector2D& value);
- void append(const QVector3D& value);
- void append(const QVector4D& value);
- void append(const QColor4ub& value);
- void append(const QVariant& value);
- void append(Qt::GlobalColor value);
- void append(const QCustomDataArray &array);
-
- QArray<float> toFloatArray() const;
- QArray<QVector2D> toVector2DArray() const;
- QArray<QVector3D> toVector3DArray() const;
- QArray<QVector4D> toVector4DArray() const;
- QArray<QColor4ub> toColorArray() const;
-
- const void *data() const;
-
-private:
- QArray<float> m_array;
- QCustomDataArray::ElementType m_elementType;
- int m_elementComponents;
-
- friend class QGLVertexBundleCustomAttribute;
- friend class QGeometryData;
-};
-
-inline QCustomDataArray::QCustomDataArray()
- : m_elementType(QCustomDataArray::Float),
- m_elementComponents(1)
-{
-}
-
-inline QCustomDataArray::QCustomDataArray(const QCustomDataArray& other)
- : m_array(other.m_array),
- m_elementType(other.m_elementType),
- m_elementComponents(other.m_elementComponents)
-{
-}
-
-inline QCustomDataArray::~QCustomDataArray() {}
-
-inline QCustomDataArray& QCustomDataArray::operator=(const QCustomDataArray& other)
-{
- if (this != &other) {
- m_array = other.m_array;
- m_elementType = other.m_elementType;
- m_elementComponents = other.m_elementComponents;
- }
- return *this;
-}
-
-inline QCustomDataArray::ElementType QCustomDataArray::elementType() const
-{
- return m_elementType;
-}
-
-inline int QCustomDataArray::size() const
-{
- return m_array.size() / m_elementComponents;
-}
-
-inline int QCustomDataArray::count() const
-{
- return m_array.size() / m_elementComponents;
-}
-
-inline int QCustomDataArray::capacity() const
-{
- return m_array.capacity() / m_elementComponents;
-}
-
-inline bool QCustomDataArray::isEmpty() const
-{
- return m_array.isEmpty();
-}
-
-inline int QCustomDataArray::elementSize() const
-{
- return m_elementComponents * sizeof(float);
-}
-
-inline void QCustomDataArray::clear()
-{
- m_array.clear();
-}
-
-inline void QCustomDataArray::reserve(int size)
-{
- m_array.reserve(size * m_elementComponents);
-}
-
-inline void QCustomDataArray::resize(int size)
-{
- m_array.resize(size * m_elementComponents);
-}
-
-inline void QCustomDataArray::squeeze()
-{
- m_array.squeeze();
-}
-
-inline void QCustomDataArray::setAt(int index, qreal x)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- Q_ASSERT(index >= 0 && index < size());
- m_array[index] = float(x);
-}
-
-inline void QCustomDataArray::setAt(int index, qreal x, qreal y)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 2;
- data[0] = float(x);
- data[1] = float(y);
-}
-
-inline void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 3;
- data[0] = float(x);
- data[1] = float(y);
- data[2] = float(z);
-}
-
-inline void QCustomDataArray::setAt(int index, qreal x, qreal y, qreal z, qreal w)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 4;
- data[0] = float(x);
- data[1] = float(y);
- data[2] = float(z);
- data[3] = float(w);
-}
-
-inline void QCustomDataArray::setAt(int index, const QVector2D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 2;
- data[0] = float(value.x());
- data[1] = float(value.y());
-}
-
-inline void QCustomDataArray::setAt(int index, const QVector3D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 3;
- data[0] = float(value.x());
- data[1] = float(value.y());
- data[2] = float(value.z());
-}
-
-inline void QCustomDataArray::setAt(int index, const QVector4D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- Q_ASSERT(index >= 0 && index < size());
- float *data = m_array.data() + index * 4;
- data[0] = float(value.x());
- data[1] = float(value.y());
- data[2] = float(value.z());
- data[3] = float(value.w());
-}
-
-inline void QCustomDataArray::setAt(int index, const QColor4ub& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- Q_ASSERT(index >= 0 && index < size());
- *(reinterpret_cast<QColor4ub *>(m_array.data() + index)) = value;
-}
-
-inline void QCustomDataArray::setAt(int index, Qt::GlobalColor value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- Q_ASSERT(index >= 0 && index < size());
- *(reinterpret_cast<QColor4ub *>(m_array.data() + index)) = QColor4ub(value);
-}
-
-inline qreal QCustomDataArray::floatAt(int index) const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- Q_ASSERT(index >= 0 && index < size());
- return m_array.at(index);
-}
-
-inline QVector2D QCustomDataArray::vector2DAt(int index) const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- Q_ASSERT(index >= 0 && index < size());
- const float *data = m_array.constData() + index * 2;
- return QVector2D(data[0], data[1]);
-}
-
-inline QVector3D QCustomDataArray::vector3DAt(int index) const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- Q_ASSERT(index >= 0 && index < size());
- const float *data = m_array.constData() + index * 3;
- return QVector3D(data[0], data[1], data[2]);
-}
-
-inline QVector4D QCustomDataArray::vector4DAt(int index) const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- Q_ASSERT(index >= 0 && index < size());
- const float *data = m_array.constData() + index * 4;
- return QVector4D(data[0], data[1], data[2], data[3]);
-}
-
-inline QColor4ub QCustomDataArray::colorAt(int index) const
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- Q_ASSERT(index >= 0 && index < size());
- return *(reinterpret_cast<const QColor4ub *>(m_array.constData() + index));
-}
-
-inline void QCustomDataArray::append(qreal x)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Float);
- m_array.append(float(x));
-}
-
-inline void QCustomDataArray::append(qreal x, qreal y)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- m_array.append(float(x), float(y));
-}
-
-inline void QCustomDataArray::append(qreal x, qreal y, qreal z)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- m_array.append(float(x), float(y), float(z));
-}
-
-inline void QCustomDataArray::append(qreal x, qreal y, qreal z, qreal w)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- m_array.append(float(x), float(y), float(z), float(w));
-}
-
-inline void QCustomDataArray::append(const QVector2D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector2D);
- m_array.append(float(value.x()), float(value.y()));
-}
-
-inline void QCustomDataArray::append(const QVector3D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector3D);
- m_array.append(float(value.x()), float(value.y()), float(value.z()));
-}
-
-inline void QCustomDataArray::append(const QVector4D& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Vector4D);
- m_array.append(float(value.x()), float(value.y()),
- float(value.z()), float(value.w()));
-}
-
-inline void QCustomDataArray::append(const QColor4ub& value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- *(reinterpret_cast<QColor4ub *>(m_array.extend(1))) = value;
-}
-
-inline void QCustomDataArray::append(Qt::GlobalColor value)
-{
- Q_ASSERT(m_elementType == QCustomDataArray::Color);
- *(reinterpret_cast<QColor4ub *>(m_array.extend(1))) = QColor4ub(value);
-}
-
-inline void QCustomDataArray::append(const QCustomDataArray &array)
-{
- Q_ASSERT(isEmpty() || (array.elementType() == elementType()));
- if (isEmpty())
- *this = array;
- else
- m_array.append(array.m_array);
-}
-
-inline const void *QCustomDataArray::data() const
-{
- return m_array.constData();
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QCustomDataArray &array);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglattributedescription.cpp b/src/threed/arrays/qglattributedescription.cpp
deleted file mode 100644
index 63ae1c34..00000000
--- a/src/threed/arrays/qglattributedescription.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglattributedescription.h"
-#include "qopenglfunctions.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAttributeDescription
- \brief The QGLAttributeDescription class encapsulates information about an OpenGL attribute value's layout and type.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- OpenGL has many functions that take a pointer to vertex attribute
- values: \c{glVertexPointer()}, \c{glNormalPointer()},
- \c{glVertexAttribPointer()}, etc. These functions typically
- take four arguments: tuple size (1, 2, 3, or 4), component type
- (e.g. GL_FLOAT), stride, and data pointer (\c{glNormalPointer()}
- does not use tuple size, assuming that it is 3). When used with
- vertex buffers, the data pointer may be an offset into the vertex
- buffer instead.
-
- QGLAttributeDescription encapsulates the vertex attribute() kind
- (QGL::Position, QGL::Normal, etc) with the type(), tupleSize(),
- and stride() information of an attribute. The companion
- QGLAttributeValue class adds the data pointer.
-
- \sa QGLAttributeValue
-*/
-
-/*!
- \fn QGLAttributeDescription::QGLAttributeDescription()
-
- Constructs a null attribute description with default parameters of
- tupleSize() and stride() set to zero, type() set to GL_FLOAT,
- and attribute() set to QGL::Position.
-
- \sa isNull()
-*/
-
-/*!
- \fn QGLAttributeDescription::QGLAttributeDescription(QGL::VertexAttribute attribute, int tupleSize, GLenum type, int stride)
-
- Constructs an attribute description with the fields \a attribute,
- \a tupleSize, \a type, and \a stride.
-*/
-
-/*!
- \fn bool QGLAttributeDescription::isNull() const
-
- Returns true if tupleSize() is zero, which indicates an unset
- attribute description; false otherwise.
-*/
-
-/*!
- \fn QGL::VertexAttribute QGLAttributeDescription::attribute() const
-
- Returns the vertex attribute that this description applies to.
- The default value is QGL::Position.
-
- \sa setAttribute(), type()
-*/
-
-/*!
- \fn void QGLAttributeDescription::setAttribute(QGL::VertexAttribute attribute)
-
- Sets the vertex \a attribute that this description applies to.
-
- \sa attribute()
-*/
-
-/*!
- \fn GLenum QGLAttributeDescription::type() const
-
- Returns the component type for this attribute description. The default
- value is GL_FLOAT.
-
- \sa setType(), sizeOfType(), attribute()
-*/
-
-/*!
- \fn void QGLAttributeDescription::setType(GLenum type)
-
- Sets the component \a type for this attribute description.
-
- \sa type(), sizeOfType()
-*/
-
-/*!
- Returns the size in bytes of type().
-
- \sa type(), tupleSize()
-*/
-int QGLAttributeDescription::sizeOfType() const
-{
- switch (m_type) {
- case GL_BYTE: return int(sizeof(GLbyte));
- case GL_UNSIGNED_BYTE: return int(sizeof(GLubyte));
- case GL_SHORT: return int(sizeof(GLshort));
- case GL_UNSIGNED_SHORT: return int(sizeof(GLushort));
- case GL_INT: return int(sizeof(GLint));
- case GL_UNSIGNED_INT: return int(sizeof(GLuint));
- case GL_FLOAT: return int(sizeof(GLfloat));
-#if defined(GL_DOUBLE) && !defined(QT_OPENGL_ES)
- case GL_DOUBLE: return int(sizeof(GLdouble));
-#endif
- default: return 0;
- }
-}
-
-/*!
- \fn int QGLAttributeDescription::tupleSize() const
-
- Returns the tuple size of this attribute in components. For example,
- a return value of 3 indicates a vector of 3-dimensional values.
- If tupleSize() is zero, then this attribute description is null.
-
- \sa setTupleSize(), isNull(), sizeOfType()
-*/
-
-/*!
- \fn void QGLAttributeDescription::setTupleSize(int tupleSize)
-
- Sets the tuple size of this attribute in components to \a tupleSize.
-
- \sa tupleSize()
-*/
-
-/*!
- \fn int QGLAttributeDescription::stride() const
-
- Returns the stride in bytes from one vertex element to the
- next for this attribute description. The default value of 0 indicates
- that the elements are tightly packed within the data array.
-
- \sa setStride()
-*/
-
-/*!
- \fn void QGLAttributeDescription::setStride(int stride)
-
- Sets the \a stride in bytes from one vertex element to the next
- for this attribute description.
-
- \sa stride()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qglattributedescription.h b/src/threed/arrays/qglattributedescription.h
deleted file mode 100644
index 4be46cc9..00000000
--- a/src/threed/arrays/qglattributedescription.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLATTRIBUTEDESCRIPTION_H
-#define QGLATTRIBUTEDESCRIPTION_H
-
-#include <QtOpenGL/qgl.h>
-#include "qt3dglobal.h"
-#include "qglnamespace.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLAttributeDescription
-{
-public:
- QGLAttributeDescription();
- QGLAttributeDescription(QGL::VertexAttribute attribute,
- int tupleSize, GLenum type, int stride);
-
- bool isNull() const;
-
- QGL::VertexAttribute attribute() const;
- void setAttribute(QGL::VertexAttribute attribute);
-
- GLenum type() const;
- void setType(GLenum type);
-
- int sizeOfType() const;
-
- int tupleSize() const;
- void setTupleSize(int tupleSize);
-
- int stride() const;
- void setStride(int stride);
-
-private:
- QGL::VertexAttribute m_attribute;
- GLenum m_type;
- int m_tupleSize;
- int m_stride;
-};
-
-inline QGLAttributeDescription::QGLAttributeDescription()
- : m_attribute(QGL::Position), m_type(GL_FLOAT),
- m_tupleSize(0), m_stride(0)
-{
-}
-
-inline QGLAttributeDescription::QGLAttributeDescription
- (QGL::VertexAttribute attribute, int tupleSize, GLenum type, int stride)
- : m_attribute(attribute), m_type(type),
- m_tupleSize(tupleSize), m_stride(stride)
-{
- Q_ASSERT(tupleSize >= 1 && tupleSize <= 4);
-}
-
-inline bool QGLAttributeDescription::isNull() const
-{
- return m_tupleSize == 0;
-}
-
-inline QGL::VertexAttribute QGLAttributeDescription::attribute() const
-{
- return m_attribute;
-}
-
-inline void QGLAttributeDescription::setAttribute(QGL::VertexAttribute attribute)
-{
- m_attribute = attribute;
-}
-
-inline GLenum QGLAttributeDescription::type() const
-{
- return m_type;
-}
-
-inline void QGLAttributeDescription::setType(GLenum type)
-{
- m_type = type;
-}
-
-inline int QGLAttributeDescription::tupleSize() const
-{
- return m_tupleSize;
-}
-
-inline void QGLAttributeDescription::setTupleSize(int tupleSize)
-{
- Q_ASSERT(tupleSize >= 1 && tupleSize <= 4);
- m_tupleSize = tupleSize;
-}
-
-inline int QGLAttributeDescription::stride() const
-{
- return m_stride;
-}
-
-inline void QGLAttributeDescription::setStride(int stride)
-{
- m_stride = stride;
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglattributeset.cpp b/src/threed/arrays/qglattributeset.cpp
deleted file mode 100644
index 469ee8fa..00000000
--- a/src/threed/arrays/qglattributeset.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglattributeset.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAttributeSet
- \brief The QGLAttributeSet class provides a set of QGL::VertexAttribute indexes.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QGLAttributeSet is intended for checking if a specific vertex
- attribute is present in a piece of geometry, or has been set on a
- QGLPainter during rendering operations. The members of the set
- are instances of QGL::VertexAttribute, with the restriction that
- the index must be between 0 and 31.
-
- The most common use for this class is to determine if specific
- attributes have been supplied on a QGLPainter so as to adjust the
- current drawing effect accordingly. The following example will
- use a lit texture effect if texture co-ordinates were provided
- in the vertex bundle, or a simple lit material effect if
- texture co-ordinates were not provided:
-
- \code
- painter.clearAttributes();
- painter.setVertexBundle(bundle);
- if (painter.attributes().contains(QGL::TextureCoord0))
- painter.setStandardEffect(QGL::LitModulateTexture2D);
- else
- painter.setStandardEffect(QGL::LitMaterial);
- \endcode
-
- It is important to clear the attributes before setting the vertex
- bundle, so that attributes from a previous bundle will not leak
- through. Multiple vertex bundles may be supplied if they contain
- different parts of the same logical piece of geometry.
-
- \sa QGLVertexBundle::attributes(), QGLPainter::attributes()
-*/
-
-/*!
- \fn QGLAttributeSet::QGLAttributeSet()
-
- Constructs an empty attribute set.
-
- \sa isEmpty()
-*/
-
-/*!
- \fn bool QGLAttributeSet::isEmpty() const
-
- Returns true if this attribute set is empty; false otherwise.
-*/
-
-/*!
- \fn void QGLAttributeSet::clear()
-
- Clears this attribute set to empty.
-*/
-
-/*!
- \fn bool QGLAttributeSet::contains(QGL::VertexAttribute attr) const
-
- Returns true if this attribute set contains \a attr; false otherwise.
-
- \sa insert(), remove()
-*/
-
-/*!
- \fn void QGLAttributeSet::insert(QGL::VertexAttribute attr)
-
- Inserts \a attr into this attribute set. Note: \a attr must be
- within the range 0 to 31. Attribute indexes outside this range
- are ignored and not added to the set.
-
- \sa remove(), contains()
-*/
-
-/*!
- \fn void QGLAttributeSet::remove(QGL::VertexAttribute attr)
-
- Removes \a attr from this attribute set.
-
- \sa insert(), contains()
-*/
-
-/*!
- Returns the members of this attribute set as a list.
-
- \sa fromList()
-*/
-QList<QGL::VertexAttribute> QGLAttributeSet::toList() const
-{
- QList<QGL::VertexAttribute> list;
- quint32 attrs = m_attrs;
- int index = 0;
- while (attrs != 0) {
- if ((attrs & 1) != 0)
- list.append(QGL::VertexAttribute(index));
- ++index;
- attrs >>= 1;
- }
- return list;
-}
-
-/*!
- Returns a new attribute set that is initialized with the members
- of \a list.
-
- \sa toList(), insert()
-*/
-QGLAttributeSet QGLAttributeSet::fromList(const QList<QGL::VertexAttribute> &list)
-{
- QGLAttributeSet set;
- for (int index = 0; index < list.size(); ++index)
- set.insert(list.at(index));
- return set;
-}
-
-/*!
- \fn void QGLAttributeSet::unite(const QGLAttributeSet &other)
-
- Unites the contents of \a other with this attribute set
- and modifies this set accordingly.
-
- \sa intersect(), subtract(), insert()
-*/
-
-/*!
- \fn void QGLAttributeSet::intersect(const QGLAttributeSet &other)
-
- Intersects the contents of \a other with this attribute set
- and modifies this set accordingly.
-
- \sa unite(), subtract()
-*/
-
-/*!
- \fn void QGLAttributeSet::subtract(const QGLAttributeSet &other)
-
- Subtracts the contents of \a other from this attribute set
- and modifies this set accordingly.
-
- \sa unite(), intersect(), remove()
-*/
-
-/*!
- \fn bool QGLAttributeSet::operator==(const QGLAttributeSet &other) const
-
- Returns true if this attribute set has the same elements as \a other;
- false otherwise.
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QGLAttributeSet::operator!=(const QGLAttributeSet &other) const
-
- Returns true if this attribute set does not have the same elements as
- \a other; false otherwise.
-
- \sa operator==()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qglattributeset.h b/src/threed/arrays/qglattributeset.h
deleted file mode 100644
index c8f10e98..00000000
--- a/src/threed/arrays/qglattributeset.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLATTRIBUTESET_H
-#define QGLATTRIBUTESET_H
-
-#include "qt3dglobal.h"
-#include "qglnamespace.h"
-#include <QtCore/qlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLAttributeSet
-{
-public:
- QGLAttributeSet() : m_attrs(0) {}
-
- bool isEmpty() const { return !m_attrs; }
- void clear() { m_attrs = 0; }
-
- bool contains(QGL::VertexAttribute attr) const;
- void insert(QGL::VertexAttribute attr);
- void remove(QGL::VertexAttribute attr);
-
- QList<QGL::VertexAttribute> toList() const;
- static QGLAttributeSet fromList(const QList<QGL::VertexAttribute> &list);
-
- void unite(const QGLAttributeSet &other);
- void intersect(const QGLAttributeSet &other);
- void subtract(const QGLAttributeSet &other);
-
- bool operator==(const QGLAttributeSet &other) const;
- bool operator!=(const QGLAttributeSet &other) const;
-
-private:
- bool isValidAttr(QGL::VertexAttribute attr) const;
-
- quint32 m_attrs;
-};
-
-inline bool QGLAttributeSet::isValidAttr(QGL::VertexAttribute attr) const
-{
- int a = int(attr);
- return (a > -1 && a < 32);
-}
-
-inline bool QGLAttributeSet::contains(QGL::VertexAttribute attr) const
-{
- quint32 flag = quint32(attr);
- return isValidAttr(attr) ? ((m_attrs & (((quint32)1) << flag)) != 0) : false;
-}
-
-inline void QGLAttributeSet::insert(QGL::VertexAttribute attr)
-{
- quint32 flag = quint32(attr);
- if (isValidAttr(attr))
- m_attrs |= (((quint32)1) << flag);
-}
-
-inline void QGLAttributeSet::remove(QGL::VertexAttribute attr)
-{
- quint32 flag = quint32(attr);
- if (isValidAttr(attr))
- m_attrs &= ~(((quint32)1) << flag);
-}
-
-inline void QGLAttributeSet::unite(const QGLAttributeSet &other)
-{
- m_attrs |= other.m_attrs;
-}
-
-inline void QGLAttributeSet::intersect(const QGLAttributeSet &other)
-{
- m_attrs &= other.m_attrs;
-}
-
-inline void QGLAttributeSet::subtract(const QGLAttributeSet &other)
-{
- m_attrs &= ~(other.m_attrs);
-}
-
-inline bool QGLAttributeSet::operator==(const QGLAttributeSet &other) const
-{
- return m_attrs == other.m_attrs;
-}
-
-inline bool QGLAttributeSet::operator!=(const QGLAttributeSet &other) const
-{
- return m_attrs != other.m_attrs;
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglattributevalue.cpp b/src/threed/arrays/qglattributevalue.cpp
deleted file mode 100644
index b5647dbf..00000000
--- a/src/threed/arrays/qglattributevalue.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglattributevalue.h"
-#include "qopenglfunctions.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAttributeValue
- \brief The QGLAttributeValue class encapsulates information about an OpenGL attribute value.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- OpenGL has many functions that take a pointer to vertex attribute
- values: \c{glVertexPointer()}, \c{glNormalPointer()},
- \c{glVertexAttribPointer()}, etc. These functions typically
- take four arguments: tuple size (1, 2, 3, or 4), component type
- (e.g. GL_FLOAT), stride, and data pointer (\c{glNormalPointer()}
- does not use tuple size, assuming that it is 3). When used with
- vertex buffers, the data pointer may be an offset into the vertex
- buffer instead.
-
- QGLAttributeValue encapsulates these four values so that they can
- be easily manipulated as a set during OpenGL painting operations.
- Constructors are provided for converting QArray and
- QCustomDataArray objects into an attribute value.
-
- Because the data() value is a raw pointer to arbitrary memory,
- care should be taken that the memory remains valid until the
- QGLAttributeValue is no longer required.
-
- \sa QGLAttributeDescription, QArray, QCustomDataArray
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue()
-
- Constructs a null attribute value with default parameters of
- tupleSize(), and stride() set to zero, type() set to GL_FLOAT,
- and data() set to null.
-
- \sa isNull()
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QArray<float>& array)
-
- Constructs an attribute value that refers to the contents of \a array,
- setting tupleSize() to 1, type() to GL_FLOAT, and stride() to zero.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QArray<QVector2D>& array)
-
- Constructs an attribute value that refers to the contents of \a array,
- setting tupleSize() to 2, type() to GL_FLOAT, and stride() to zero.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QArray<QVector3D>& array)
-
- Constructs an attribute value that refers to the contents of \a array,
- setting tupleSize() to 3, type() to GL_FLOAT, and stride() to zero.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QArray<QVector4D>& array)
-
- Constructs an attribute value that refers to the contents of \a array,
- setting tupleSize() to 4, type() to GL_FLOAT, and stride() to zero.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QArray<QColor4ub>& array)
-
- Constructs an attribute value that refers to the contents of \a array,
- setting tupleSize() to 4, type() to GL_UNSIGNED_BYTE, and stride() to zero.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-
-/*!
- Constructs an attribute value that refers to the contents of \a array.
- The tupleSize() and type() of the attribute value will be set according
- to the QCustomDataArray::elementType() of \a array.
-
- The \a array must not be destroyed or modified until the attribute
- value is no longer required.
-*/
-QGLAttributeValue::QGLAttributeValue(const QCustomDataArray& array)
- : m_tupleSize(0), m_type(GL_FLOAT), m_stride(0)
- , m_data(array.data()), m_count(array.count())
-{
- switch (array.elementType()) {
- case QCustomDataArray::Float:
- m_tupleSize = 1;
- break;
- case QCustomDataArray::Vector2D:
- m_tupleSize = 2;
- break;
- case QCustomDataArray::Vector3D:
- m_tupleSize = 3;
- break;
- case QCustomDataArray::Vector4D:
- m_tupleSize = 4;
- break;
- case QCustomDataArray::Color:
- m_tupleSize = 4;
- m_type = GL_UNSIGNED_BYTE;
- break;
- }
-}
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(int tupleSize, GLenum type, int stride, const void *data, int count)
-
- Constructs an attribute value with the fields \a tupleSize, \a type,
- \a stride, \a data, and \a count.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(int tupleSize, GLenum type, int stride, int offset, int count)
-
- Constructs an attribute value with the fields \a tupleSize, \a type,
- \a stride, \a offset, and \a count.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QGLAttributeDescription& description, const void *data, int count)
-
- Constructs an attribute value with the supplied \a description,
- \a data, and \a count.
-*/
-
-/*!
- \fn QGLAttributeValue::QGLAttributeValue(const QGLAttributeDescription& description, int offset, int count)
-
- Constructs an attribute value with the supplied \a description,
- \a offset, and \a count.
-*/
-
-/*!
- \fn bool QGLAttributeValue::isNull() const
-
- Returns true if tupleSize() is zero, which indicates an unset
- attribute value; false otherwise.
-
- Note: it is possible for data() to be null, but isNull() returns true.
- This can happen when data() is actually a zero offset into a
- vertex buffer.
-*/
-
-/*!
- \fn QGLAttributeDescription QGLAttributeValue::description(QGL::VertexAttribute attribute) const
-
- Returns the description of this value, tagged with \a attribute.
-
- \sa type()
-*/
-
-/*!
- \fn GLenum QGLAttributeValue::type() const
-
- Returns the component type for this attribute value. The default
- value is GL_FLOAT.
-
- \sa sizeOfType(), description()
-*/
-
-/*!
- Returns the size in bytes of type().
-
- \sa type(), tupleSize()
-*/
-int QGLAttributeValue::sizeOfType() const
-{
- switch (m_type) {
- case GL_BYTE: return int(sizeof(GLbyte));
- case GL_UNSIGNED_BYTE: return int(sizeof(GLubyte));
- case GL_SHORT: return int(sizeof(GLshort));
- case GL_UNSIGNED_SHORT: return int(sizeof(GLushort));
- case GL_INT: return int(sizeof(GLint));
- case GL_UNSIGNED_INT: return int(sizeof(GLuint));
- case GL_FLOAT: return int(sizeof(GLfloat));
-#if defined(GL_DOUBLE) && !defined(QT_OPENGL_ES)
- case GL_DOUBLE: return int(sizeof(GLdouble));
-#endif
- default: return 0;
- }
-}
-
-/*!
- \fn int QGLAttributeValue::tupleSize() const
-
- Returns the tuple size of this attribute in components. For example,
- a return value of 3 indicates a vector of 3-dimensional values.
- If tupleSize() is zero, then this attribute value is null.
-
- \sa isNull(), sizeOfType()
-*/
-
-/*!
- \fn int QGLAttributeValue::stride() const
-
- Returns the stride in bytes from one vertex element to the
- next for this attribute value. The default value of 0 indicates
- that the elements are tightly packed within the data() array.
-*/
-
-/*!
- \fn const void *QGLAttributeValue::data() const
-
- Returns the data pointer for the elements in this attribute value.
-*/
-
-/*!
- \fn int QGLAttributeValue::count() const
-
- Returns the count of vertex elements in this attribute value;
- zero if the count is unknown.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qglattributevalue.h b/src/threed/arrays/qglattributevalue.h
deleted file mode 100644
index 00da039a..00000000
--- a/src/threed/arrays/qglattributevalue.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLATTRIBUTEVALUE_H
-#define QGLATTRIBUTEVALUE_H
-
-#include "qglattributedescription.h"
-#include "qcustomdataarray.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLVertexBundle;
-
-class Q_QT3D_EXPORT QGLAttributeValue
-{
-public:
- QGLAttributeValue();
- QGLAttributeValue(const QArray<float>& array);
- QGLAttributeValue(const QArray<QVector2D>& array);
- QGLAttributeValue(const QArray<QVector3D>& array);
- QGLAttributeValue(const QArray<QVector4D>& array);
- QGLAttributeValue(const QArray<QColor4ub>& array);
- QGLAttributeValue(const QCustomDataArray& array);
- QGLAttributeValue(int tupleSize, GLenum type, int stride, const void *data, int count = 0);
- QGLAttributeValue(int tupleSize, GLenum type, int stride, int offset, int count = 0);
- QGLAttributeValue(const QGLAttributeDescription& description, const void *data, int count = 0);
- QGLAttributeValue(const QGLAttributeDescription& description, int offset, int count = 0);
-
- bool isNull() const;
-
- QGLAttributeDescription description(QGL::VertexAttribute attribute) const;
- GLenum type() const;
- int sizeOfType() const;
- int tupleSize() const;
- int stride() const;
- const void *data() const;
- int count() const;
-
-private:
- int m_tupleSize;
- GLenum m_type;
- int m_stride;
- const void *m_data;
- int m_count;
-
- void setStride(int stride) { m_stride = stride; }
- void setOffset(int offset)
- { m_data = reinterpret_cast<const void *>(offset); }
-
- friend class QGLVertexBundle;
-};
-
-inline QGLAttributeValue::QGLAttributeValue()
- : m_tupleSize(0), m_type(GL_FLOAT), m_stride(0), m_data(0), m_count(0)
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue(const QArray<float>& array)
- : m_tupleSize(1), m_type(GL_FLOAT), m_stride(0)
- , m_data(array.constData()), m_count(array.count())
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue(const QArray<QVector2D>& array)
- : m_tupleSize(2), m_type(GL_FLOAT), m_stride(0)
- , m_data(array.constData()), m_count(array.count())
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue(const QArray<QVector3D>& array)
- : m_tupleSize(3), m_type(GL_FLOAT), m_stride(0)
- , m_data(array.constData()), m_count(array.count())
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue(const QArray<QVector4D>& array)
- : m_tupleSize(4), m_type(GL_FLOAT), m_stride(0)
- , m_data(array.constData()), m_count(array.count())
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue(const QArray<QColor4ub>& array)
- : m_tupleSize(4), m_type(GL_UNSIGNED_BYTE), m_stride(0)
- , m_data(array.constData()), m_count(array.count())
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue
- (int tupleSize, GLenum type, int stride, const void *data, int count)
- : m_tupleSize(tupleSize), m_type(type), m_stride(stride)
- , m_data(data), m_count(count)
-{
- Q_ASSERT(tupleSize >= 1 && tupleSize <= 4);
-}
-
-inline QGLAttributeValue::QGLAttributeValue
- (int tupleSize, GLenum type, int stride, int offset, int count)
- : m_tupleSize(tupleSize), m_type(type), m_stride(stride)
- , m_data(reinterpret_cast<const void *>(offset)), m_count(count)
-{
- Q_ASSERT(tupleSize >= 1 && tupleSize <= 4);
-}
-
-inline QGLAttributeValue::QGLAttributeValue
- (const QGLAttributeDescription& description, const void *data, int count)
- : m_tupleSize(description.tupleSize()), m_type(description.type())
- , m_stride(description.stride()), m_data(data), m_count(count)
-{
-}
-
-inline QGLAttributeValue::QGLAttributeValue
- (const QGLAttributeDescription& description, int offset, int count)
- : m_tupleSize(description.tupleSize()), m_type(description.type())
- , m_stride(description.stride())
- , m_data(reinterpret_cast<const void *>(offset))
- , m_count(count)
-{
-}
-
-inline bool QGLAttributeValue::isNull() const
-{
- return m_tupleSize == 0;
-}
-
-inline QGLAttributeDescription QGLAttributeValue::description(QGL::VertexAttribute attribute) const
-{
- if (!isNull()) {
- return QGLAttributeDescription(attribute, m_tupleSize, m_type, m_stride);
- } else {
- QGLAttributeDescription desc;
- desc.setAttribute(attribute);
- return desc;
- }
-}
-
-inline GLenum QGLAttributeValue::type() const
-{
- return m_type;
-}
-
-inline int QGLAttributeValue::tupleSize() const
-{
- return m_tupleSize;
-}
-
-inline int QGLAttributeValue::stride() const
-{
- return m_stride;
-}
-
-inline const void *QGLAttributeValue::data() const
-{
- return m_data;
-}
-
-inline int QGLAttributeValue::count() const
-{
- return m_count;
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglindexbuffer.cpp b/src/threed/arrays/qglindexbuffer.cpp
deleted file mode 100644
index 55802551..00000000
--- a/src/threed/arrays/qglindexbuffer.cpp
+++ /dev/null
@@ -1,777 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglindexbuffer.h"
-#include "qglpainter.h"
-#include "qglpainter_p.h"
-#include "qglext_p.h"
-#include <QtOpenGL/qgl.h>
-#include <QtCore/qatomic.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLIndexBuffer
- \brief The QGLIndexBuffer class manages uploading of index arrays into a GL server.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-*/
-
-#ifdef QT_OPENGL_ES
-
-static bool qt_has_uint_buffers()
-{
- static bool done = false;
- static bool answer = false;
- if (!done) {
- QGLExtensionChecker extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
- answer = extensions.match("GL_OES_element_index_uint");
- done = true;
- }
- return answer;
-}
-
-#endif
-
-class QGLIndexBufferPrivate
-{
-public:
- QGLIndexBufferPrivate()
- : indexCount(0)
- , elementType(GL_UNSIGNED_SHORT)
- , buffer(QGLBuffer::IndexBuffer)
-#ifdef QT_OPENGL_ES
- , hasIntBuffers(qt_has_uint_buffers())
-#else
- , hasIntBuffers(true)
-#endif
- {
- ref = 1;
- }
-
- QBasicAtomicInt ref;
- int indexCount;
- QArray<ushort> indexesShort;
- QArray<uint> indexesInt;
- GLenum elementType;
- QGLBuffer buffer;
- bool hasIntBuffers;
-
- void append(const QGLIndexBufferPrivate *other, uint offset, int start);
- uint headIndex(int posn) const;
- uint tailIndex(int posn) const;
-};
-
-/*!
- Creates a new index buffer.
-*/
-QGLIndexBuffer::QGLIndexBuffer()
- : d_ptr(new QGLIndexBufferPrivate)
-{
-}
-
-/*!
- Creates a copy of \a other. Note that this just copies a reference
- to the index buffer. Any modifications to the copy will also
- affect the original object.
-*/
-QGLIndexBuffer::QGLIndexBuffer(const QGLIndexBuffer& other)
- : d_ptr(other.d_ptr)
-{
- d_ptr->ref.ref();
-}
-
-/*!
- Destroys this index buffer if this object is the last reference to it.
-*/
-QGLIndexBuffer::~QGLIndexBuffer()
-{
- if (!d_ptr->ref.deref())
- delete d_ptr;
-}
-
-/*!
- Assigns \a other to this object. Note that this just assigns a
- reference to the \a other index buffer. Any modifications to this
- object will also affect \a other.
-*/
-QGLIndexBuffer& QGLIndexBuffer::operator=(const QGLIndexBuffer& other)
-{
- if (d_ptr != other.d_ptr) {
- if (!d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- d_ptr->ref.ref();
- }
- return *this;
-}
-
-/*!
- Returns the indexes in this buffer as an array of ushort values.
-
- Returns an empty array if type() is not \c GL_UNSIGNED_SHORT or the
- buffer has already been uploaded.
-*/
-QArray<ushort> QGLIndexBuffer::indexesUShort() const
-{
- Q_D(const QGLIndexBuffer);
- return d->indexesShort;
-}
-
-/*!
- Returns the indexes in this buffer as an array of uint values.
-
- Returns an empty array if type() is not \c GL_UNSIGNED_INT or the
- buffer has already been uploaded.
-*/
-QArray<uint> QGLIndexBuffer::indexesUInt() const
-{
- Q_D(const QGLIndexBuffer);
- return d->indexesInt;
-}
-
-/*!
- Returns the usage pattern for this index buffer.
- The default value is QGLBuffer::StaticDraw.
-
- \sa setUsagePattern()
-*/
-QGLBuffer::UsagePattern QGLIndexBuffer::usagePattern() const
-{
- Q_D(const QGLIndexBuffer);
- return d->buffer.usagePattern();
-}
-
-/*!
- Sets the usage pattern for this index buffer to \a value.
- This function must be called before upload() for the \a value
- to take effect.
-
- \sa usagePattern(), upload()
-*/
-void QGLIndexBuffer::setUsagePattern(QGLBuffer::UsagePattern value)
-{
- Q_D(QGLIndexBuffer);
- d->buffer.setUsagePattern(value);
-}
-
-static QArray<ushort> qt_qarray_uint_to_ushort(const QArray<uint> &array)
-{
- QArray<ushort> result;
- const uint *values = array.constData();
- int size = array.size();
- bool largeValue = false;
- result.reserve(size);
- while (size-- > 0) {
- uint value = *values++;
- if (ushort(value) != value)
- largeValue = true;
- result.append(ushort(value));
- }
- if (largeValue)
- qWarning("QGLIndexBuffer::setIndexes: large 32-bit value provided to a 16-bit only buffer");
- return result;
-}
-
-/*!
- Sets the index \a values in this index buffer, replacing the
- entire current contents.
-
- If the index buffer has been uploaded to the GL server, then this
- function must be called with a current GL context that is compatible
- with the uploaded buffer.
-
- \sa replaceIndexes()
-*/
-void QGLIndexBuffer::setIndexes(const QArray<ushort>& values)
-{
- Q_D(QGLIndexBuffer);
- if (d->buffer.isCreated()) {
- d->buffer.bind();
- d->buffer.allocate(values.constData(), values.size() * sizeof(ushort));
- d->buffer.release();
- // The element type may have changed from int to ushort.
- d->elementType = GL_UNSIGNED_SHORT;
- } else {
- d->indexesShort = values;
- d->elementType = GL_UNSIGNED_SHORT;
- d->indexesInt = QArray<uint>();
- }
- d->indexCount = values.size();
-}
-
-/*!
- Sets the index \a values in this index buffer, replacing the
- entire current contents.
-
- If the index buffer has been uploaded to the GL server, then this
- function must be called with a current GL context that is compatible
- with the uploaded buffer.
-
- OpenGL/ES systems usually do not support 32-bit index values unless
- they have a special extension for that purpose. On systems without
- 32-bit index values, this function will need to convert all values
- to 16-bit which may incur a performance penalty and lose information.
-
- \sa replaceIndexes()
-*/
-void QGLIndexBuffer::setIndexes(const QArray<uint>& values)
-{
- Q_D(QGLIndexBuffer);
- if (d->buffer.isCreated()) {
- if (d->hasIntBuffers) {
- d->buffer.bind();
- d->buffer.allocate(values.constData(), values.size() * sizeof(int));
- d->buffer.release();
- // The element type may have changed from ushort to int.
- d->elementType = GL_UNSIGNED_INT;
- } else {
- QArray<ushort> svalues = qt_qarray_uint_to_ushort(values);
- d->buffer.bind();
- d->buffer.allocate(svalues.constData(), svalues.size() * sizeof(ushort));
- d->buffer.release();
- }
- } else if (d->hasIntBuffers) {
- d->indexesInt = values;
- d->elementType = GL_UNSIGNED_INT;
- d->indexesShort = QArray<ushort>();
- } else {
- d->indexesShort = qt_qarray_uint_to_ushort(values);
- d->elementType = GL_UNSIGNED_SHORT;
- d->indexesInt = QArray<uint>();
- }
- d->indexCount = values.size();
-}
-
-/*!
- Replaces the elements of this index buffer, starting at \a index,
- with the contents of \a values. All other elements keep their
- current values.
-
- If the index buffer has been uploaded to the GL server, then this
- function must be called with a current GL context that is compatible
- with the uploaded buffer.
-
- The index buffer must have been originally created with the
- ushort element type.
-
- \sa setIndexes()
-*/
-void QGLIndexBuffer::replaceIndexes(int index, const QArray<ushort>& values)
-{
- Q_D(QGLIndexBuffer);
- Q_ASSERT_X(d->elementType == GL_UNSIGNED_SHORT,
- "QGLIndexBuffer::replaceIndexes()",
- "buffer created with int element type, replacing with ushort");
- if (d->elementType != GL_UNSIGNED_SHORT)
- return;
- if (d->buffer.isCreated()) {
- d->buffer.bind();
- d->buffer.write(index * sizeof(ushort),
- values.constData(), values.size() * sizeof(ushort));
- d->buffer.release();
- } else {
- d->indexesShort.replace(index, values.constData(), values.size());
- d->indexCount = d->indexesShort.size();
- }
-}
-
-/*!
- Replaces the elements of this index buffer, starting at \a index,
- with the contents of \a values. All other elements keep their
- current values.
-
- If the index buffer has been uploaded to the GL server, then this
- function must be called with a current GL context that is compatible
- with the uploaded buffer.
-
- The index buffer must have been originally created with the
- int element type.
-
- OpenGL/ES systems usually do not support 32-bit index values unless
- they have a special extension for that purpose. On systems without
- 32-bit index values, this function will need to convert all values
- to 16-bit which may incur a performance penalty and lose information.
-
- \sa setIndexes()
-*/
-void QGLIndexBuffer::replaceIndexes(int index, const QArray<uint>& values)
-{
- Q_D(QGLIndexBuffer);
- Q_ASSERT_X(d->elementType == GL_UNSIGNED_INT || !d->hasIntBuffers,
- "QGLIndexBuffer::replaceIndexes()",
- "buffer created with ushort element type, replacing with int");
- if (d->elementType != GL_UNSIGNED_INT && d->hasIntBuffers)
- return;
- if (d->buffer.isCreated()) {
- if (d->hasIntBuffers) {
- d->buffer.bind();
- d->buffer.write(index * sizeof(int),
- values.constData(), values.size() * sizeof(int));
- d->buffer.release();
- } else {
- QArray<ushort> svalues = qt_qarray_uint_to_ushort(values);
- d->buffer.bind();
- d->buffer.write(index * sizeof(ushort),
- svalues.constData(),
- svalues.size() * sizeof(ushort));
- d->buffer.release();
- }
- } else if (d->elementType == GL_UNSIGNED_INT) {
- d->indexesInt.replace(index, values.constData(), values.size());
- d->indexCount = d->indexesInt.size();
- } else {
- QArray<ushort> svalues = qt_qarray_uint_to_ushort(values);
- d->indexesShort.replace(index, svalues.constData(), svalues.size());
- d->indexCount = d->indexesShort.size();
- }
-}
-
-/*!
- Returns the element type for this index buffer, \c{GL_UNSIGNED_SHORT}
- or \c{GL_UNSIGNED_INT}.
-*/
-GLenum QGLIndexBuffer::elementType() const
-{
- Q_D(const QGLIndexBuffer);
- return d->elementType;
-}
-
-/*!
- Returns the number of indexes in this index buffer.
-*/
-int QGLIndexBuffer::indexCount() const
-{
- Q_D(const QGLIndexBuffer);
- return d->indexCount;
-}
-
-/*!
- \fn bool QGLIndexBuffer::isEmpty() const
-
- Returns true if indexCount() is zero; false otherwise.
-*/
-
-/*!
- Uploads the index data specified by a previous setIndexes()
- call into the GL server as an index buffer object.
-
- Returns true if the data could be uploaded; false if index buffer
- objects are not supported or there is insufficient memory to complete
- the request. Returns true if the data was already uploaded.
-
- Once the index data has been uploaded, the client-side copies of
- the data arrays will be released. If the index data could not be
- uploaded, then it is retained client-side. This way, regardless of
- whether the data could be uploaded or not, QGLPainter::draw() can
- be used to support drawing of primitives using this object.
-
- \sa isUploaded(), setIndexes(), QGLPainter::draw()
-*/
-bool QGLIndexBuffer::upload()
-{
- Q_D(QGLIndexBuffer);
- if (d->buffer.isCreated())
- return true;
- if (!d->buffer.create())
- return false;
- d->buffer.bind();
- if (d->elementType == GL_UNSIGNED_SHORT) {
- d->buffer.allocate(d->indexesShort.constData(),
- d->indexesShort.size() * sizeof(ushort));
- d->indexesShort = QArray<ushort>();
- } else {
- d->buffer.allocate(d->indexesInt.constData(),
- d->indexesInt.size() * sizeof(int));
- d->indexesInt = QArray<uint>();
- }
- d->buffer.release();
- return true;
-}
-
-/*!
- Returns true if the index data specified by previous a setIndexes()
- call has been uploaded into the GL server; false otherwise.
-
- \sa upload(), setIndexes()
-*/
-bool QGLIndexBuffer::isUploaded() const
-{
- Q_D(const QGLIndexBuffer);
- return d->buffer.isCreated();
-}
-
-/*!
- Returns the QGLBuffer in use by this index buffer object,
- so that its properties or contents can be modified directly.
-
- \sa isUploaded()
-*/
-QGLBuffer QGLIndexBuffer::buffer() const
-{
- Q_D(const QGLIndexBuffer);
- return d->buffer;
-}
-
-/*!
- Binds this index buffer to the current GL context. Returns false if
- binding was not possible, usually because upload() has not been called.
-
- The buffer must be bound to the same QGLContext current when upload()
- was called, or to another QGLContext that is sharing with it.
- Otherwise, false will be returned from this function.
-
- \sa release(), upload()
-*/
-bool QGLIndexBuffer::bind()
-{
- Q_D(QGLIndexBuffer);
- return d->buffer.bind();
-}
-
-/*!
- Releases this index buffer from the current GL context.
-
- This function must be called with the same QGLContext current
- as when bind() was called on the index buffer.
-
- \sa bind()
-*/
-void QGLIndexBuffer::release()
-{
- Q_D(QGLIndexBuffer);
- d->buffer.release();
-}
-
-void QGLIndexBufferPrivate::append
- (const QGLIndexBufferPrivate *other, uint offset, int start)
-{
- if (elementType == GL_UNSIGNED_SHORT &&
- other->elementType == GL_UNSIGNED_SHORT) {
- // Both buffers are ushort.
- const ushort *data = other->indexesShort.constData() + start;
- int count = other->indexesShort.count() - start;
- indexesShort.reserve(indexesShort.count() + count);
- indexCount += count;
- while (count-- > 0)
- indexesShort.append(ushort(*data++ + offset));
- } else if (elementType == GL_UNSIGNED_SHORT) {
- // Only first buffer is ushort: convert it to int first.
- const ushort *indexes = indexesShort.constData();
- int count = indexesShort.count();
- indexesInt.reserve(count + other->indexesInt.count());
- while (count-- > 0)
- indexesInt.append(*indexes++);
- indexesShort = QArray<ushort>();
- elementType = GL_UNSIGNED_INT;
- const uint *data = other->indexesInt.constData() + start;
- count = other->indexesInt.count() - start;
- indexCount += count;
- while (count-- > 0)
- indexesInt.append(*data++ + offset);
- } else if (other->elementType == GL_UNSIGNED_SHORT) {
- // Only second buffer is ushort.
- const ushort *data = other->indexesShort.constData() + start;
- int count = other->indexesShort.count() - start;
- indexesInt.reserve(indexesInt.count() + count);
- indexCount += count;
- while (count-- > 0)
- indexesInt.append(*data++ + offset);
- } else {
- // Neither buffer is ushort.
- const uint *data = other->indexesInt.constData() + start;
- int count = other->indexesInt.count() - start;
- indexesInt.reserve(indexesInt.count() + count);
- indexCount += count;
- while (count-- > 0)
- indexesInt.append(*data++ + offset);
- }
-}
-
-uint QGLIndexBufferPrivate::headIndex(int posn) const
-{
- if (indexCount <= posn)
- return uint(-1);
- if (elementType == GL_UNSIGNED_SHORT)
- return indexesShort[posn];
- else
- return indexesInt[posn];
-}
-
-uint QGLIndexBufferPrivate::tailIndex(int posn) const
-{
- if (indexCount <= posn)
- return uint(-1);
- if (elementType == GL_UNSIGNED_SHORT)
- return indexesShort[indexCount - posn - 1];
- else
- return indexesInt[indexCount - posn - 1];
-}
-
-/*!
- Appends the contents of \a buffer to this index buffer and adds
- \a offset to all of the entries in \a buffer.
-
- This function is typically used to combine multiple geometry meshes
- into a single mesh that can be bound as a single buffer.
-
- The request is ignored if this index buffer or \a buffer have already
- been uploaded, or \a buffer is this index buffer.
-
- \sa isUploaded(), setIndexes()
-*/
-void QGLIndexBuffer::append(const QGLIndexBuffer &buffer, uint offset)
-{
- Q_D(QGLIndexBuffer);
- const QGLIndexBufferPrivate *dbuf = buffer.d_ptr;
-
- // Bail out if the buffers are uploaded or identical.
- if (d->buffer.isCreated() || dbuf->buffer.isCreated())
- return;
- if (d == dbuf)
- return;
-
- // Append the two index arrays.
- d->append(dbuf, offset, 0);
-}
-
-/*!
- Appends the contents of \a buffer to this index buffer and adds
- \a offset to all of the entries in \a buffer.
-
- The two buffers will be merged at the join point according to
- \a combineMode. For example, if \a combineMode is QGL::TriangleStrip,
- then the result will be a single triangle strip. Indexes are
- dropped from the front of \a buffer as necessary to correctly
- merge the buffers.
-
- This function is typically used to combine multiple geometry meshes
- into a single mesh that can be bound as a single buffer.
-
- The request is ignored if this index buffer or \a buffer have already
- been uploaded, or \a buffer is this index buffer.
-
- \sa isUploaded(), setIndexes()
-*/
-void QGLIndexBuffer::append
- (const QGLIndexBuffer &buffer, uint offset, QGL::DrawingMode combineMode)
-{
- Q_D(QGLIndexBuffer);
- const QGLIndexBufferPrivate *dbuf = buffer.d_ptr;
-
- // Bail out if the buffers are uploaded or identical.
- if (d->buffer.isCreated() || dbuf->buffer.isCreated())
- return;
- if (d == dbuf)
- return;
-
- // Determine how to combine the buffers.
- switch (int(combineMode)) {
- case QGL::Points:
- case QGL::Lines:
- case QGL::Triangles:
- case QGL::LinesAdjacency:
- case QGL::TrianglesAdjacency:
- case 0x0007: // GL_QUADS
- // These can be done by just appending the raw data with no changes.
- d->append(dbuf, offset, 0);
- break;
-
- case QGL::LineLoop:
- case QGL::LineStrip:
- case 0x0009: // GL_POLYGON
- // Join the last index of the first buffer to the first
- // index of the second buffer to continue the loop or strip.
- if (d->tailIndex(0) == (dbuf->headIndex(0) + offset))
- d->append(dbuf, offset, 1);
- else
- d->append(dbuf, offset, 0);
- break;
-
- case QGL::TriangleStrip:
- // Join the last two indexes of the first buffer to the first
- // two indexes of the second buffer to continue the strip.
- // It is possible that the first two indexes of the second
- // buffer may be reversed for strip continuation depending
- // upon whether the first strip is odd or even in length.
- if (d->tailIndex(1) == (dbuf->headIndex(0) + offset) &&
- d->tailIndex(0) == (dbuf->headIndex(1) + offset))
- d->append(dbuf, offset, 2);
- else if (d->tailIndex(1) == (dbuf->headIndex(1) + offset) &&
- d->tailIndex(0) == (dbuf->headIndex(0) + offset))
- d->append(dbuf, offset, 2);
- else
- d->append(dbuf, offset, 0);
- break;
-
- case 0x0008: // GL_QUAD_STRIP
- // Join the last two indexes of the first buffer to the first
- // two indexes of the second buffer to continue the strip.
- if (d->tailIndex(1) == (dbuf->headIndex(0) + offset) &&
- d->tailIndex(0) == (dbuf->headIndex(1) + offset))
- d->append(dbuf, offset, 2);
- else
- d->append(dbuf, offset, 0);
- break;
-
- case QGL::TriangleFan:
- // The first index of both buffers should be the same, and the
- // last index of the first buffer should be the same as the second
- // index of the second buffer.
- if (d->headIndex(0) == (dbuf->headIndex(0) + offset) &&
- d->tailIndex(0) == (dbuf->headIndex(1) + offset))
- d->append(dbuf, offset, 2);
- else
- d->append(dbuf, offset, 0);
- break;
-
- case QGL::LineStripAdjacency:
- // Join the last three indexes of the first buffer to the first
- // three indexes of the second buffer to continue the strip.
- if (d->tailIndex(2) == (dbuf->headIndex(0) + offset) &&
- d->tailIndex(1) == (dbuf->headIndex(1) + offset) &&
- d->tailIndex(0) == (dbuf->headIndex(2) + offset))
- d->append(dbuf, offset, 3);
- else
- d->append(dbuf, offset, 0);
- break;
-
- case QGL::TriangleStripAdjacency:
- // Fourth last and second last of first buffer need to be the
- // same as the first and third of the second buffer.
- if (d->tailIndex(3) == (dbuf->headIndex(0) + offset) &&
- d->tailIndex(1) == (dbuf->headIndex(2) + offset))
- d->append(dbuf, offset, 4);
- else
- d->append(dbuf, offset, 0);
- break;
-
- default:
- qWarning("QGLIndexBuffer::append: unknown drawing mode 0x%04x",
- int(combineMode));
- break;
- }
-}
-
-/*!
- \overload
-
- Draws primitives using vertices from the arrays specified by
- setVertexAttribute(). The type of primitive to draw is
- specified by \a mode.
-
- This operation will consume all of the elements of \a indexes,
- which are used to index into the enabled arrays.
-
- If \a indexes has not been uploaded to the GL server as an index
- buffer, then this function will draw using a client-side array.
-
- \sa update(), QGLIndexBuffer::upload()
-*/
-void QGLPainter::draw(QGL::DrawingMode mode, const QGLIndexBuffer& indexes)
-{
- QGLIndexBufferPrivate *d = const_cast<QGLIndexBufferPrivate *>(indexes.d_func());
- update();
- GLuint id = d->buffer.bufferId();
- if (id != d_ptr->boundIndexBuffer) {
- if (id)
- d->buffer.bind();
- else
- QGLBuffer::release(QGLBuffer::IndexBuffer);
- d_ptr->boundIndexBuffer = id;
- }
- if (id) {
- glDrawElements(GLenum(mode), d->indexCount, d->elementType, 0);
- } else if (d->elementType == GL_UNSIGNED_SHORT) {
- glDrawElements(GLenum(mode), d->indexCount, GL_UNSIGNED_SHORT,
- d->indexesShort.constData());
- } else {
- glDrawElements(GLenum(mode), d->indexCount, GL_UNSIGNED_INT,
- d->indexesInt.constData());
- }
-}
-
-/*!
- \overload
-
- Draws primitives using vertices from the arrays specified by
- setVertexAttribute(). The type of primitive to draw is
- specified by \a mode.
-
- This operation will consume \a count elements of \a indexes,
- starting at \a offset, which are used to index into the enabled arrays.
-
- If \a indexes has not been uploaded to the GL server as an index
- buffer, then this function will draw using a client-side array.
-
- \sa update(), QGLIndexBuffer::upload()
-*/
-void QGLPainter::draw(QGL::DrawingMode mode, const QGLIndexBuffer& indexes, int offset, int count)
-{
- QGLIndexBufferPrivate *d = const_cast<QGLIndexBufferPrivate *>(indexes.d_func());
- update();
- GLuint id = d->buffer.bufferId();
- if (id != d_ptr->boundIndexBuffer) {
- if (id)
- d->buffer.bind();
- else
- QGLBuffer::release(QGLBuffer::IndexBuffer);
- d_ptr->boundIndexBuffer = id;
- }
- if (id) {
- if (d->elementType == GL_UNSIGNED_SHORT) {
- glDrawElements(GLenum(mode), count, GL_UNSIGNED_SHORT,
- reinterpret_cast<const void *>(offset * sizeof(ushort)));
- } else {
- glDrawElements(GLenum(mode), count, GL_UNSIGNED_INT,
- reinterpret_cast<const void *>(offset * sizeof(int)));
- }
- } else if (d->elementType == GL_UNSIGNED_SHORT) {
- glDrawElements(GLenum(mode), count, GL_UNSIGNED_SHORT,
- d->indexesShort.constData() + offset);
- } else {
- glDrawElements(GLenum(mode), count, GL_UNSIGNED_INT,
- d->indexesInt.constData() + offset);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qglindexbuffer.h b/src/threed/arrays/qglindexbuffer.h
deleted file mode 100644
index e1a54971..00000000
--- a/src/threed/arrays/qglindexbuffer.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLINDEXBUFFER_H
-#define QGLINDEXBUFFER_H
-
-#include <QtOpenGL/qgl.h>
-#include <QtOpenGL/qglbuffer.h>
-#include "qglnamespace.h"
-#include "qarray.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLIndexBufferPrivate;
-class QGLPainter;
-
-class Q_QT3D_EXPORT QGLIndexBuffer
-{
-public:
- QGLIndexBuffer();
- QGLIndexBuffer(const QGLIndexBuffer& other);
- ~QGLIndexBuffer();
-
- QGLIndexBuffer& operator=(const QGLIndexBuffer& other);
-
- QGLBuffer::UsagePattern usagePattern() const;
- void setUsagePattern(QGLBuffer::UsagePattern value);
-
- QArray<ushort> indexesUShort() const;
- QArray<uint> indexesUInt() const;
-
- void setIndexes(const QArray<ushort>& values);
- void setIndexes(const QArray<uint>& values);
-
- void replaceIndexes(int index, const QArray<ushort>& values);
- void replaceIndexes(int index, const QArray<uint>& values);
-
- GLenum elementType() const;
-
- int indexCount() const;
- bool isEmpty() const { return indexCount() == 0; }
-
- bool upload();
- bool isUploaded() const;
-
- QGLBuffer buffer() const;
-
- bool bind();
- void release();
-
- void append(const QGLIndexBuffer &buffer, uint offset);
- void append(const QGLIndexBuffer &buffer, uint offset, QGL::DrawingMode combineMode);
-
-private:
- QGLIndexBufferPrivate *d_ptr;
-
- Q_DECLARE_PRIVATE(QGLIndexBuffer)
-
- friend class QGLPainter;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglvertexbundle.cpp b/src/threed/arrays/qglvertexbundle.cpp
deleted file mode 100644
index f2e14b9d..00000000
--- a/src/threed/arrays/qglvertexbundle.cpp
+++ /dev/null
@@ -1,495 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglvertexbundle.h"
-#include "qglvertexbundle_p.h"
-#include "qglabstracteffect.h"
-#include <QtCore/qlist.h>
-#include <QtCore/qatomic.h>
-#include <QtOpenGL/qglshaderprogram.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLVertexBundle
- \brief The QGLVertexBundle class bundles vertex attribute arrays for efficient uploading into a GL server.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QGLVertexBundle provides an implementation of a static vertex
- buffer, where the vertex attributes are supplied once at construction
- time and then never modified until the bundle is destroyed.
- When the vertex attributes are sent ot the GL server by upload(),
- they may be repacked for greater drawing efficiency.
-
- For general-purpose vertex buffers that can be allocated and modified
- in-place, use QGLBuffer instead.
-*/
-
-/*!
- Constructs a new vertex bundle.
-*/
-QGLVertexBundle::QGLVertexBundle()
- : d_ptr(new QGLVertexBundlePrivate())
-{
-}
-
-/*!
- Creates a copy of \a other. Note that this just copies a reference
- to the vertex bundle. Any modifications to the copy will also
- affect the original object.
-*/
-QGLVertexBundle::QGLVertexBundle(const QGLVertexBundle& other)
- : d_ptr(other.d_ptr)
-{
- d_ptr->ref.ref();
-}
-
-/*!
- Destroys this vertex bundle if this object is the last reference to it.
-*/
-QGLVertexBundle::~QGLVertexBundle()
-{
- if (!d_ptr->ref.deref())
- delete d_ptr;
-}
-
-/*!
- Assigns \a other to this object. Note that this just assigns a
- reference to the \a other vertex bundle. Any modifications to this
- object will also affect \a other.
-*/
-QGLVertexBundle& QGLVertexBundle::operator=(const QGLVertexBundle& other)
-{
- if (d_ptr != other.d_ptr) {
- if (!d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- d_ptr->ref.ref();
- }
- return *this;
-}
-
-/*!
- Adds the floating-point array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QArray<float>& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleFloatAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-/*!
- Adds the 2D vector array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QArray<QVector2D>& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleVector2DAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-/*!
- Adds the 3D vector array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QArray<QVector3D>& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleVector3DAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-/*!
- Adds the 4D vector array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QArray<QVector4D>& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleVector4DAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-/*!
- Adds the color array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QArray<QColor4ub>& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleColorAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-/*!
- Adds the custom data array \a value to this vertex bundle as the
- data for \a attribute.
-
- \sa upload()
-*/
-void QGLVertexBundle::addAttribute
- (QGL::VertexAttribute attribute, const QCustomDataArray& value)
-{
- Q_D(QGLVertexBundle);
- if (!d->buffer.isCreated()) {
- d->attributeSet.insert(attribute);
- d->attributes +=
- new QGLVertexBundleCustomAttribute(attribute, value);
- d->vertexCount = qMax(d->vertexCount, value.count());
- }
-}
-
-// Interleave a source array into a destination array.
-static void vertexBufferInterleave
- (float *dst, int dstStride, const float *src, int srcStride, int count)
-{
- switch (srcStride) {
- case 1:
- while (count-- > 0) {
- dst[0] = src[0];
- ++src;
- dst += dstStride;
- }
- break;
- case 2:
- while (count-- > 0) {
- dst[0] = src[0];
- dst[1] = src[1];
- src += 2;
- dst += dstStride;
- }
- break;
- case 3:
- while (count-- > 0) {
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- src += 3;
- dst += dstStride;
- }
- break;
- case 4:
- while (count-- > 0) {
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- src += 4;
- dst += dstStride;
- }
- break;
- default:
- while (count-- > 0) {
- for (int component = 0; component < srcStride; ++component)
- dst[component] = src[component];
- src += srcStride;
- dst += dstStride;
- }
- break;
- }
-}
-
-/*!
- Returns the set of attributes that are present in this vertex bundle.
-*/
-QGLAttributeSet QGLVertexBundle::attributes() const
-{
- Q_D(const QGLVertexBundle);
- return d->attributeSet;
-}
-
-/*!
- Returns the raw attribute value associated with \a attribute in
- this vertex bundle; null if \a attribute does not exist in the
- vertex bundle.
-
- If isUploaded() is true, then the returned value will contain a
- buffer offset to the attribute. If isUploaded() is false,
- then the returned value will contain a client-side data pointer
- to the attribute.
-
- \sa addAttribute()
-*/
-QGLAttributeValue QGLVertexBundle::attributeValue(QGL::VertexAttribute attribute) const
-{
- Q_D(const QGLVertexBundle);
- QGLVertexBundleAttribute *attr = 0;
- int attrIndex;
- for (attrIndex = 0; attrIndex < d->attributes.size(); ++attrIndex) {
- attr = d->attributes[attrIndex];
- if (attr->attribute == attribute)
- return attr->value;
- }
- return QGLAttributeValue();
-}
-
-/*!
- Returns the number of vertices that were defined by previous
- called to addAttribute().
-
- \sa addAttribute()
-*/
-int QGLVertexBundle::vertexCount() const
-{
- Q_D(const QGLVertexBundle);
- return d->vertexCount;
-}
-
-/*!
- \fn bool QGLVertexBundle::isEmpty() const
-
- Returns true if vertexCount() is zero; false otherwise.
-*/
-
-/*!
- Uploads the vertex data specified by previous addAttribute()
- calls into the GL server as a vertex buffer object.
-
- Returns true if the data could be uploaded; false if vertex buffer
- objects are not supported or there is insufficient memory to complete
- the request. Returns true if the data was already uploaded.
-
- Once the vertex data has been uploaded, the client-side copies of
- the data arrays will be released. If the vertex data could not be
- uploaded, then it is retained client-side. This way, regardless of
- whether the data could be uploaded or not, QGLPainter::setVertexBundle()
- can be used to support drawing of primitives using this object.
-
- \sa isUploaded(), addAttribute(), QGLPainter::setVertexBundle()
-*/
-bool QGLVertexBundle::upload()
-{
- Q_D(QGLVertexBundle);
- QGLVertexBundleAttribute *attr;
-
- // Nothing to do if already uploaded or there are no attributes.
- if (d->buffer.isCreated())
- return true;
- if (d->attributes.isEmpty())
- return false;
-
- // Create the VBO in the GL server and bind it.
- if (!d->buffer.create())
- return false;
- d->buffer.bind();
-
- // If there is only one attribute, then realloc and write in one step.
- if (d->attributes.size() == 1) {
- attr = d->attributes[0];
- d->buffer.allocate(attr->value.data(),
- attr->count() * attr->elementSize());
- attr->value.setOffset(0);
- attr->clear();
- d->buffer.release();
- return true;
- }
-
- // Calculate the total size of the VBO that we will need,
- // the maximum number of interleaved vertices, and the
- // interleaved stride.
- int size = 0;
- int stride = 0;
- int maxCount = 0;
- for (int index = 0; index < d->attributes.size(); ++index) {
- attr = d->attributes[index];
- int count = attr->count();
- if (count > maxCount)
- maxCount = count;
- int elemSize = attr->elementSize();
- size += count * elemSize;
- stride += elemSize;
- }
- int bufferSize = size;
- d->buffer.allocate(bufferSize);
- stride /= sizeof(float);
-
- // Determine how to upload the data, using a map if possible.
- // Interleave the data into the final buffer. We do it in
- // sections so as to keep locality problems to a minimum.
- void *mapped = d->buffer.map(QGLBuffer::WriteOnly);
- int offset = 0;
- QArray<float> temp;
- float *dst;
- if (mapped)
- dst = reinterpret_cast<float *>(mapped);
- else
- dst = temp.extend(1024);
- int sectionSize = 1024 / stride;
- for (int vertex = 0; vertex < maxCount; vertex += sectionSize) {
- int attrPosn = 0;
- for (int index = 0; index < d->attributes.size(); ++index) {
- attr = d->attributes[index];
- int count = attr->count() - vertex;
- if (count <= 0)
- continue;
- count = qMin(count, sectionSize);
- int components = attr->elementSize() / sizeof(float);
- vertexBufferInterleave
- (dst + attrPosn, stride,
- reinterpret_cast<const float *>(attr->value.data()) +
- vertex * components,
- components, count);
- attrPosn += attr->elementSize() / sizeof(float);
- }
- size = sectionSize * stride;
- if (mapped) {
- dst += size;
- } else {
- size *= sizeof(float);
- if ((offset + size) > bufferSize) // buffer overflow check
- size = bufferSize-offset;
- d->buffer.write(offset, dst, size);
- offset += size;
- }
- }
- offset = 0;
- for (int index = 0; index < d->attributes.size(); ++index) {
- attr = d->attributes[index];
- attr->value.setOffset(offset);
- attr->value.setStride(stride * sizeof(float));
- offset += attr->elementSize();
- attr->clear();
- }
- if (mapped)
- d->buffer.unmap();
-
- // Buffer is uploaded and ready to go.
- d->buffer.release();
- return true;
-}
-
-/*!
- Returns true if the vertex data specified by previous addAttribute()
- calls has been uploaded into the GL server; false otherwise.
-
- \sa upload(), addAttribute()
-*/
-bool QGLVertexBundle::isUploaded() const
-{
- Q_D(const QGLVertexBundle);
- return d->buffer.isCreated();
-}
-
-/*!
- Returns the QGLBuffer in use by this vertex bundle object,
- so that its properties or contents can be modified directly.
-
- \sa isUploaded()
-*/
-QGLBuffer QGLVertexBundle::buffer() const
-{
- Q_D(const QGLVertexBundle);
- return d->buffer;
-}
-
-/*!
- Binds the vertex buffer associated with this bundle to the current GL
- context. Returns false if binding was not possible, usually because
- upload() has not been called.
-
- The buffer must be bound to the same QGLContext current when upload()
- was called, or to another QGLContext that is sharing with it.
- Otherwise, false will be returned from this function.
-
- \sa release(), upload()
-*/
-bool QGLVertexBundle::bind()
-{
- Q_D(QGLVertexBundle);
- return d->buffer.bind();
-}
-
-/*!
- Releases the vertex buffer associated with this bundle from the
- current GL context.
-
- This function must be called with the same QGLContext current
- as when bind() was called on the vertex buffer.
-
- \sa bind()
-*/
-void QGLVertexBundle::release()
-{
- Q_D(QGLVertexBundle);
- d->buffer.release();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qglvertexbundle.h b/src/threed/arrays/qglvertexbundle.h
deleted file mode 100644
index fb978eb4..00000000
--- a/src/threed/arrays/qglvertexbundle.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLVERTEXBUNDLE_H
-#define QGLVERTEXBUNDLE_H
-
-#include <QtOpenGL/qglbuffer.h>
-#include "qcustomdataarray.h"
-#include "qglattributevalue.h"
-#include "qglattributeset.h"
-#include <QtCore/qlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLVertexBundlePrivate;
-class QGLPainter;
-class QGLAbstractEffect;
-class QGLShaderProgram;
-
-class Q_QT3D_EXPORT QGLVertexBundle
-{
-public:
- QGLVertexBundle();
- QGLVertexBundle(const QGLVertexBundle& other);
- ~QGLVertexBundle();
-
- QGLVertexBundle& operator=(const QGLVertexBundle& other);
-
- void addAttribute(QGL::VertexAttribute attribute,
- const QArray<float>& value);
- void addAttribute(QGL::VertexAttribute attribute,
- const QArray<QVector2D>& value);
- void addAttribute(QGL::VertexAttribute attribute,
- const QArray<QVector3D>& value);
- void addAttribute(QGL::VertexAttribute attribute,
- const QArray<QVector4D>& value);
- void addAttribute(QGL::VertexAttribute attribute,
- const QArray<QColor4ub>& value);
- void addAttribute(QGL::VertexAttribute attribute,
- const QCustomDataArray& value);
-
- QGLAttributeSet attributes() const;
-
- QGLAttributeValue attributeValue(QGL::VertexAttribute attribute) const;
-
- int vertexCount() const;
- bool isEmpty() const { return vertexCount() == 0; }
-
- bool upload();
- bool isUploaded() const;
-
- QGLBuffer buffer() const;
-
- bool bind();
- void release();
-
-private:
- QGLVertexBundlePrivate *d_ptr;
-
- Q_DECLARE_PRIVATE(QGLVertexBundle)
-
- friend class QGLPainter;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qglvertexbundle_p.h b/src/threed/arrays/qglvertexbundle_p.h
deleted file mode 100644
index eb4672fe..00000000
--- a/src/threed/arrays/qglvertexbundle_p.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLVERTEXBUNDLE_P_H
-#define QGLVERTEXBUNDLE_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.
-//
-
-#include "qglvertexbundle.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleAttribute(QGL::VertexAttribute attr) : attribute(attr) {}
- virtual ~QGLVertexBundleAttribute() {}
-
- virtual void clear() = 0;
- virtual QGLAttributeValue uploadValue() = 0;
- virtual int count() = 0;
- virtual int elementSize() = 0;
-
- QGL::VertexAttribute attribute;
- QGLAttributeValue value;
-};
-
-class QGLVertexBundleFloatAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleFloatAttribute
- (QGL::VertexAttribute attr, const QArray<float>& array)
- : QGLVertexBundleAttribute(attr), floatArray(array)
- {
- value = QGLAttributeValue(floatArray);
- }
-
- void clear() { floatArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(floatArray); }
- int count() { return floatArray.count(); }
- int elementSize() { return sizeof(float); }
-
- QArray<float> floatArray;
-};
-
-class QGLVertexBundleVector2DAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleVector2DAttribute
- (QGL::VertexAttribute attr, const QArray<QVector2D>& array)
- : QGLVertexBundleAttribute(attr), vector2DArray(array)
- {
- value = QGLAttributeValue(vector2DArray);
- }
-
- void clear() { vector2DArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(vector2DArray); }
- int count() { return vector2DArray.count(); }
- int elementSize() { return sizeof(QVector2D); }
-
- QArray<QVector2D> vector2DArray;
-};
-
-class QGLVertexBundleVector3DAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleVector3DAttribute
- (QGL::VertexAttribute attr, const QArray<QVector3D>& array)
- : QGLVertexBundleAttribute(attr), vector3DArray(array)
- {
- value = QGLAttributeValue(vector3DArray);
- }
-
- void clear() { vector3DArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(vector3DArray); }
- int count() { return vector3DArray.count(); }
- int elementSize() { return sizeof(QVector3D); }
-
- QArray<QVector3D> vector3DArray;
-};
-
-class QGLVertexBundleVector4DAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleVector4DAttribute
- (QGL::VertexAttribute attr, const QArray<QVector4D>& array)
- : QGLVertexBundleAttribute(attr), vector4DArray(array)
- {
- value = QGLAttributeValue(vector4DArray);
- }
-
- void clear() { vector4DArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(vector4DArray); }
- int count() { return vector4DArray.count(); }
- int elementSize() { return sizeof(QVector4D); }
-
- QArray<QVector4D> vector4DArray;
-};
-
-class QGLVertexBundleColorAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleColorAttribute
- (QGL::VertexAttribute attr, const QArray<QColor4ub>& array)
- : QGLVertexBundleAttribute(attr), colorArray(array)
- {
- value = QGLAttributeValue(colorArray);
- }
-
- void clear() { colorArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(colorArray); }
- int count() { return colorArray.count(); }
- int elementSize() { return sizeof(QColor4ub); }
-
- QArray<QColor4ub> colorArray;
-};
-
-class QGLVertexBundleCustomAttribute : public QGLVertexBundleAttribute
-{
-public:
- QGLVertexBundleCustomAttribute
- (QGL::VertexAttribute attr, const QCustomDataArray& array)
- : QGLVertexBundleAttribute(attr), customArray(array)
- {
- value = QGLAttributeValue(customArray);
- }
-
- void clear() { customArray.clear(); }
- QGLAttributeValue uploadValue()
- { return QGLAttributeValue(customArray); }
- int count() { return customArray.count(); }
- int elementSize() { return customArray.elementSize(); }
-
- QCustomDataArray customArray;
-};
-
-class QGLVertexBundlePrivate
-{
-public:
- QGLVertexBundlePrivate()
- : buffer(QGLBuffer::VertexBuffer),
- vertexCount(0)
- {
- ref = 1;
- }
- ~QGLVertexBundlePrivate()
- {
- qDeleteAll(attributes);
- }
-
- QBasicAtomicInt ref;
- QGLBuffer buffer;
- QList<QGLVertexBundleAttribute *> attributes;
- int vertexCount;
- QGLAttributeSet attributeSet;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qvector2darray.cpp b/src/threed/arrays/qvector2darray.cpp
deleted file mode 100644
index 2617cb5f..00000000
--- a/src/threed/arrays/qvector2darray.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qvector2darray.h"
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QVector2DArray
- \brief The QVector2DArray class is a convenience for wrapping a QArray of QVector2D values.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QVector2DArray is used to build an array of 2D vector values
- based on floating-point x and y arguments:
-
- \code
- QVector2DArray array;
- array.append(1.0f, 2.0f);
- array.append(-1.0f, 2.0f);
- array.append(1.0f, -2.0f);
- \endcode
-
- This is more convenient and readable than the equivalent with
- QArray:
-
- \code
- QArray<QVector2D> array;
- array.append(QVector2D(1.0f, 2.0f));
- array.append(QVector2D(-1.0f, 2.0f));
- array.append(QVector2D(1.0f, -2.0f));
- \endcode
-
- QVector2DArray also has convenience functions for transforming
- the contents of the array with translate(), translated(),
- transform(), and transformed().
-
- \sa QArray, QVector3DArray, QVector4DArray
-*/
-
-/*!
- \fn QVector2DArray::QVector2DArray()
-
- Constructs an empty array of QVector2D values.
-*/
-
-/*!
- \fn QVector2DArray::QVector2DArray(int size, const QVector2D& value)
-
- Constructs an array of QVector2D values with an initial \a size.
- All elements in the array are initialized to \a value.
-*/
-
-/*!
- \fn QVector2DArray::QVector2DArray(const QArray<QVector2D>& other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn void QVector2DArray::append(qreal x, qreal y)
- \overload
-
- Appends (\a x, \a y) to this array of QVector2D values.
-*/
-
-/*!
- \fn void QVector2DArray::append(const QPointF& point)
- \overload
-
- Appends \a point to this array of QVector2D values.
-*/
-
-/*!
- \fn void QVector2DArray::append(const QPoint& point);
- \overload
-
- Appends \a point to this array of QVector2D values.
-*/
-
-/*!
- Multiplies the elements in this array of QVector2D values by
- the \a scale.
-
- \sa scaled()
-*/
-void QVector2DArray::scale(qreal scale)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector2D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ *= scale;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector2D> result;
- int size = count();
- const QVector2D *src = constData();
- QVector2D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector2D values, multiplied
- by the \a scale.
-
- \sa scale()
-*/
-QVector2DArray QVector2DArray::scaled(qreal scale) const
-{
- const qreal identity = 1.0;
- if (qFuzzyCompare(scale, identity))
- return *this;
- QArray<QVector2D> result;
- int size = count();
- const QVector2D *src = constData();
- QVector2D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- return result;
-}
-
-/*!
- Translates the elements in this array of QVector2D values
- by the components of \a value.
-
- \sa translated()
-*/
-void QVector2DArray::translate(const QVector2D& value)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector2D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ += value;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector2D> result;
- int size = count();
- const QVector2D *src = constData();
- QVector2D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- *this = result;
- }
-}
-
-/*!
- \fn void QVector2DArray::translate(qreal x, qreal y)
- \overload
-
- Translates the elements in this array of QVector2D values
- by (\a x, \a y).
-
- \sa translated()
-*/
-
-/*!
- Returns a copy of this array of QVector2D values, translated
- by the components of \a value.
-
- \sa translate()
-*/
-QArray<QVector2D> QVector2DArray::translated(const QVector2D& value) const
-{
- QArray<QVector2D> result;
- int size = count();
- QVector2D *dst = result.extend(size);
- const QVector2D *src = constData();
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- return result;
-}
-
-/*!
- \fn QArray<QVector2D> QVector2DArray::translated(qreal x, qreal y) const
- \overload
-
- Returns a copy of this array of QVector2D values, translated
- by (\a x, \a y).
-
- \sa translate()
-*/
-
-/*!
- Transforms the elements in this array of QVector2D values
- by \a matrix.
-
- \sa transformed()
-*/
-void QVector2DArray::transform(const QMatrix4x4& matrix)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector2D *dst = data();
- for (int index = 0; index < size; ++index) {
- *dst = (matrix * QVector3D(*dst, 0.0f)).toVector2D();
- ++dst;
- }
- } else {
- // Create a new array, transform the values, and assign.
- QArray<QVector2D> result;
- int size = count();
- const QVector2D *src = constData();
- QVector2D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = (matrix * QVector3D(*src++, 0.0f)).toVector2D();
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector2D values,
- transformed by \a matrix.
-
- \sa transform()
-*/
-QArray<QVector2D> QVector2DArray::transformed(const QMatrix4x4& matrix) const
-{
- QArray<QVector2D> result;
- int size = count();
- const QVector2D *src = constData();
- QVector2D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = (matrix * QVector3D(*src++, 0.0f)).toVector2D();
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qvector2darray.h b/src/threed/arrays/qvector2darray.h
deleted file mode 100644
index df6087ff..00000000
--- a/src/threed/arrays/qvector2darray.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QVECTOR2DARRAY_H
-#define QVECTOR2DARRAY_H
-
-#include "qarray.h"
-#include <QtGui/qvector2d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QVector2DArray : public QArray<QVector2D>
-{
-public:
- QVector2DArray();
- QVector2DArray(int size, const QVector2D& value = QVector2D());
- QVector2DArray(const QArray<QVector2D>& other);
-
- void append(qreal x, qreal y);
- void append(const QPointF& point);
- void append(const QPoint& point);
-
- void scale(qreal scale);
- QVector2DArray scaled(qreal scale) const;
-
- void translate(const QVector2D& value);
- void translate(qreal x, qreal y);
-
- QArray<QVector2D> translated(const QVector2D& value) const;
- QArray<QVector2D> translated(qreal x, qreal y) const;
-
- void transform(const QMatrix4x4& matrix);
- QArray<QVector2D> transformed(const QMatrix4x4& matrix) const;
-
-#if !defined(Q_NO_USING_KEYWORD) || defined(Q_QDOC)
- using QArray<QVector2D>::append;
-#else
- inline void append(const QVector2D& value)
- { QArray<QVector2D>::append(value); }
- inline void append(const QVector2D& value1, const QVector2D& value2)
- { QArray<QVector2D>::append(value1, value2); }
- inline void append(const QVector2D& value1, const QVector2D& value2, const QVector2D& value3)
- { QArray<QVector2D>::append(value1, value2, value3); }
- inline void append(const QVector2D& value1, const QVector2D& value2, const QVector2D& value3, const QVector2D& value4)
- { QArray<QVector2D>::append(value1, value2, value3, value4); }
- inline void append(const QVector2D *values, int count)
- { QArray<QVector2D>::append(values, count); }
- inline void append(const QArray<QVector2D>& other)
- { QArray<QVector2D>::append(other); }
-#endif
-};
-
-inline QVector2DArray::QVector2DArray() {}
-
-inline QVector2DArray::QVector2DArray(int size, const QVector2D& value)
- : QArray<QVector2D>(size, value) {}
-
-inline QVector2DArray::QVector2DArray(const QArray<QVector2D>& other)
- : QArray<QVector2D>(other) {}
-
-inline void QVector2DArray::append(qreal x, qreal y)
- { QArray<QVector2D>::append(QVector2D(x, y)); }
-
-inline void QVector2DArray::append(const QPointF& point)
- { QArray<QVector2D>::append(QVector2D(point)); }
-
-inline void QVector2DArray::append(const QPoint& point)
- { QArray<QVector2D>::append(QVector2D(point)); }
-
-inline void QVector2DArray::translate(qreal x, qreal y)
- { translate(QVector2D(x, y)); }
-
-inline QArray<QVector2D> QVector2DArray::translated(qreal x, qreal y) const
- { return translated(QVector2D(x, y)); }
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qvector3darray.cpp b/src/threed/arrays/qvector3darray.cpp
deleted file mode 100644
index f72dda46..00000000
--- a/src/threed/arrays/qvector3darray.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qvector3darray.h"
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QVector3DArray
- \brief The QVector3DArray class is a convenience for wrapping a QArray of QVector3D values.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QVector3DArray is used to build an array of 3D vector values
- based on floating-point x, y, and z arguments:
-
- \code
- QVector3DArray array;
- array.append(1.0f, 2.0f, 3.0f);
- array.append(-1.0f, 2.0f, 3.0f);
- array.append(1.0f, -2.0f, 3.0f);
- \endcode
-
- This is more convenient and readable than the equivalent with
- QArray:
-
- \code
- QArray<QVector3D> array;
- array.append(QVector3D(1.0f, 2.0f, 3.0f));
- array.append(QVector3D(-1.0f, 2.0f, 3.0f));
- array.append(QVector3D(1.0f, -2.0f, 3.0f));
- \endcode
-
- QVector3DArray also has convenience functions for transforming
- the contents of the array with translate(), translated(),
- transform(), and transformed().
-
- \sa QArray, QVector2DArray, QVector4DArray
-*/
-
-/*!
- \fn QVector3DArray::QVector3DArray()
-
- Constructs an empty array of QVector3D values.
-*/
-
-/*!
- \fn QVector3DArray::QVector3DArray(int size, const QVector3D& value)
-
- Constructs an array of QVector3D values with an initial \a size.
- All elements in the array are initialized to \a value.
-*/
-
-/*!
- \fn QVector3DArray::QVector3DArray(const QArray<QVector3D>& other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn void QVector3DArray::append(qreal x, qreal y, qreal z)
-
- Appends (\a x, \a y, \a z) to this array of QVector3D values.
-*/
-
-/*!
- Multiplies the elements in this array of QVector3D values by
- the \a scale.
-
- \sa scaled()
-*/
-void QVector3DArray::scale(qreal scale)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector3D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ *= scale;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector3D values, multiplied
- by the \a scale.
-
- \sa scale()
-*/
-QVector3DArray QVector3DArray::scaled(qreal scale) const
-{
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- return result;
-}
-
-/*!
- Translates the elements in this array of QVector3D values
- by the components of \a value.
-
- \sa translated()
-*/
-void QVector3DArray::translate(const QVector3D& value)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector3D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ += value;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- *this = result;
- }
-}
-
-/*!
- \fn void QVector3DArray::translate(qreal x, qreal y, qreal z)
- \overload
-
- Translates the elements in this array of QVector3D values
- by (\a x, \a y, \a z).
-
- \sa translated()
-*/
-
-/*!
- Returns a copy of this array of QVector3D values, translated
- by the components of \a value.
-
- \sa translate()
-*/
-QArray<QVector3D> QVector3DArray::translated(const QVector3D& value) const
-{
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- return result;
-}
-
-/*!
- \fn QArray<QVector3D> QVector3DArray::translated(qreal x, qreal y, qreal z) const
- \overload
-
- Returns a copy of this array of QVector3D values, translated
- by (\a x, \a y, \a z).
-
- \sa translate()
-*/
-
-/*!
- Transforms the elements in this array of QVector3D values
- by \a matrix.
-
- \sa transformed()
-*/
-void QVector3DArray::transform(const QMatrix4x4& matrix)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector3D *dst = data();
- for (int index = 0; index < size; ++index) {
- *dst = matrix * *dst;
- ++dst;
- }
- } else {
- // Create a new array, transform the values, and assign.
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = matrix * *src++;
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector3D values, transformed
- by \a matrix.
-
- \sa transform()
-*/
-QArray<QVector3D> QVector3DArray::transformed(const QMatrix4x4& matrix) const
-{
- QArray<QVector3D> result;
- int size = count();
- const QVector3D *src = constData();
- QVector3D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = matrix * *src++;
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qvector3darray.h b/src/threed/arrays/qvector3darray.h
deleted file mode 100644
index acab2538..00000000
--- a/src/threed/arrays/qvector3darray.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QVECTOR3DARRAY_H
-#define QVECTOR3DARRAY_H
-
-#include "qarray.h"
-#include <QtGui/qvector3d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QVector3DArray : public QArray<QVector3D>
-{
-public:
- QVector3DArray();
- QVector3DArray(int size, const QVector3D& value = QVector3D());
- QVector3DArray(const QArray<QVector3D>& other);
-
- void append(qreal x, qreal y, qreal z);
-
- void scale(qreal scale);
- QVector3DArray scaled(qreal scale) const;
-
- void translate(const QVector3D& value);
- void translate(qreal x, qreal y, qreal z);
-
- QArray<QVector3D> translated(const QVector3D& value) const;
- QArray<QVector3D> translated(qreal x, qreal y, qreal z) const;
-
- void transform(const QMatrix4x4& matrix);
- QArray<QVector3D> transformed(const QMatrix4x4& matrix) const;
-
-#if !defined(Q_NO_USING_KEYWORD) || defined(Q_QDOC)
- using QArray<QVector3D>::append;
-#else
- inline void append(const QVector3D& value)
- { QArray<QVector3D>::append(value); }
- inline void append(const QVector3D& value1, const QVector3D& value2)
- { QArray<QVector3D>::append(value1, value2); }
- inline void append(const QVector3D& value1, const QVector3D& value2, const QVector3D& value3)
- { QArray<QVector3D>::append(value1, value2, value3); }
- inline void append(const QVector3D& value1, const QVector3D& value2, const QVector3D& value3, const QVector3D& value4)
- { QArray<QVector3D>::append(value1, value2, value3, value4); }
- inline void append(const QVector3D *values, int count)
- { QArray<QVector3D>::append(values, count); }
- inline void append(const QArray<QVector3D>& other)
- { QArray<QVector3D>::append(other); }
-#endif
-};
-
-inline QVector3DArray::QVector3DArray() {}
-
-inline QVector3DArray::QVector3DArray(int size, const QVector3D& value)
- : QArray<QVector3D>(size, value) {}
-
-inline QVector3DArray::QVector3DArray(const QArray<QVector3D>& other)
- : QArray<QVector3D>(other) {}
-
-inline void QVector3DArray::append(qreal x, qreal y, qreal z)
- { QArray<QVector3D>::append(QVector3D(x, y, z)); }
-
-inline void QVector3DArray::translate(qreal x, qreal y, qreal z)
- { translate(QVector3D(x, y, z)); }
-
-inline QArray<QVector3D> QVector3DArray::translated(qreal x, qreal y, qreal z) const
- { return translated(QVector3D(x, y, z)); }
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/arrays/qvector4darray.cpp b/src/threed/arrays/qvector4darray.cpp
deleted file mode 100644
index df06ba97..00000000
--- a/src/threed/arrays/qvector4darray.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qvector4darray.h"
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QVector4DArray
- \brief The QVector4DArray class is a convenience for wrapping a QArray of QVector4D values.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::arrays
-
- QVector4DArray is used to build an array of 4D vector values
- based on floating-point x, y, and z arguments:
-
- \code
- QVector4DArray array;
- array.append(1.0f, 2.0f, 3.0f, -4.0f);
- array.append(-1.0f, 2.0f, 3.0f, -4.0f);
- array.append(1.0f, -2.0f, 3.0f, -4.0f);
- \endcode
-
- This is more convenient and readable than the equivalent with
- QArray:
-
- \code
- QArray<QVector4D> array;
- array.append(QVector4D(1.0f, 2.0f, 3.0f, -4.0f));
- array.append(QVector4D(-1.0f, 2.0f, 3.0f, -4.0f));
- array.append(QVector4D(1.0f, -2.0f, 3.0f, -4.0f));
- \endcode
-
- QVector4DArray also has convenience functions for transforming
- the contents of the array with translate(), translated(),
- transform(), and transformed().
-
- \sa QArray, QVector2DArray, QVector3DArray
-*/
-
-/*!
- \fn QVector4DArray::QVector4DArray()
-
- Constructs an empty array of QVector4D values.
-*/
-
-/*!
- \fn QVector4DArray::QVector4DArray(int size, const QVector4D& value)
-
- Constructs an array of QVector4D values with an initial \a size.
- All elements in the array are initialized to \a value.
-*/
-
-/*!
- \fn QVector4DArray::QVector4DArray(const QArray<QVector4D>& other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn void QVector4DArray::append(qreal x, qreal y, qreal z, qreal w)
-
- Appends (\a x, \a y, \a z, \a w) to this array of QVector4D values.
-*/
-
-/*!
- Multiplies the elements in this array of QVector4D values by
- the \a scale.
-
- \sa scaled()
-*/
-void QVector4DArray::scale(qreal scale)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector4D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ *= scale;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector4D values, multiplied
- by the \a scale.
-
- \sa scale()
-*/
-QVector4DArray QVector4DArray::scaled(qreal scale) const
-{
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ * scale;
- return result;
-}
-
-/*!
- Translates the elements in this array of QVector4D values
- by the components of \a value.
-
- \sa translated()
-*/
-void QVector4DArray::translate(const QVector4D& value)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector4D *dst = data();
- for (int index = 0; index < size; ++index)
- *dst++ += value;
- } else {
- // Create a new array, translate the values, and assign.
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- *this = result;
- }
-}
-
-/*!
- \fn void QVector4DArray::translate(qreal x, qreal y, qreal z, qreal w);
- \overload
-
- Translates the elements in this array of QVector4D values
- by (\a x, \a y, \a z, \a w).
-
- \sa translated()
-*/
-
-/*!
- Returns a copy of this array of QVector4D values, translated
- by the components of \a value.
-
- \sa translate()
-*/
-QArray<QVector4D> QVector4DArray::translated(const QVector4D& value) const
-{
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = *src++ + value;
- return result;
-}
-
-/*!
- \fn QArray<QVector4D> QVector4DArray::translated(qreal x, qreal y, qreal z, qreal w) const
- \overload
-
- Returns a copy of this array of QVector4D values, translated
- by (\a x, \a y, \a z, \a w).
-
- \sa translate()
-*/
-
-/*!
- Transforms the elements in this array of QVector4D values
- by \a matrix.
-
- \sa transformed()
-*/
-void QVector4DArray::transform(const QMatrix4x4& matrix)
-{
- if (isDetached()) {
- // Modify the array in-place.
- int size = count();
- QVector4D *dst = data();
- for (int index = 0; index < size; ++index) {
- *dst = matrix * *dst;
- ++dst;
- }
- } else {
- // Create a new array, transform the values, and assign.
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = matrix * *src++;
- *this = result;
- }
-}
-
-/*!
- Returns a copy of this array of QVector3D values, transformed
- by \a matrix.
-
- \sa transform()
-*/
-QArray<QVector4D> QVector4DArray::transformed(const QMatrix4x4& matrix) const
-{
- QArray<QVector4D> result;
- int size = count();
- const QVector4D *src = constData();
- QVector4D *dst = result.extend(size);
- for (int index = 0; index < size; ++index)
- *dst++ = matrix * *src++;
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/arrays/qvector4darray.h b/src/threed/arrays/qvector4darray.h
deleted file mode 100644
index 4d215fad..00000000
--- a/src/threed/arrays/qvector4darray.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QVECTOR4DARRAY_H
-#define QVECTOR4DARRAY_H
-
-#include "qarray.h"
-#include <QtGui/qvector4d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QVector4DArray : public QArray<QVector4D>
-{
-public:
- QVector4DArray();
- QVector4DArray(int size, const QVector4D& value = QVector4D());
- QVector4DArray(const QArray<QVector4D>& other);
-
- void append(qreal x, qreal y, qreal z, qreal w);
-
- void scale(qreal scale);
- QVector4DArray scaled(qreal scale) const;
-
- void translate(const QVector4D& value);
- void translate(qreal x, qreal y, qreal z, qreal w);
-
- QArray<QVector4D> translated(const QVector4D& value) const;
- QArray<QVector4D> translated
- (qreal x, qreal y, qreal z, qreal w) const;
-
- void transform(const QMatrix4x4& matrix);
- QArray<QVector4D> transformed(const QMatrix4x4& matrix) const;
-
-#if !defined(Q_NO_USING_KEYWORD) || defined(Q_QDOC)
- using QArray<QVector4D>::append;
-#else
- inline void append(const QVector4D& value)
- { QArray<QVector4D>::append(value); }
- inline void append(const QVector4D& value1, const QVector4D& value2)
- { QArray<QVector4D>::append(value1, value2); }
- inline void append(const QVector4D& value1, const QVector4D& value2, const QVector4D& value3)
- { QArray<QVector4D>::append(value1, value2, value3); }
- inline void append(const QVector4D& value1, const QVector4D& value2, const QVector4D& value3, const QVector4D& value4)
- { QArray<QVector4D>::append(value1, value2, value3, value4); }
- inline void append(const QVector4D *values, int count)
- { QArray<QVector4D>::append(values, count); }
- inline void append(const QArray<QVector4D>& other)
- { QArray<QVector4D>::append(other); }
-#endif
-};
-
-inline QVector4DArray::QVector4DArray() {}
-
-inline QVector4DArray::QVector4DArray(int size, const QVector4D& value)
- : QArray<QVector4D>(size, value) {}
-
-inline QVector4DArray::QVector4DArray(const QArray<QVector4D>& other)
- : QArray<QVector4D>(other) {}
-
-inline void QVector4DArray::append(qreal x, qreal y, qreal z, qreal w)
- { QArray<QVector4D>::append(QVector4D(x, y, z, w)); }
-
-inline void QVector4DArray::translate(qreal x, qreal y, qreal z, qreal w)
- { translate(QVector4D(x, y, z, w)); }
-
-inline QArray<QVector4D> QVector4DArray::translated
- (qreal x, qreal y, qreal z, qreal w) const
- { return translated(QVector4D(x, y, z, w)); }
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/effects/effects.pri b/src/threed/effects/effects.pri
deleted file mode 100644
index 2afeca52..00000000
--- a/src/threed/effects/effects.pri
+++ /dev/null
@@ -1,26 +0,0 @@
-
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- effects/qglshaderprogrameffect.h \
- effects/qglcolladafxeffectfactory.h \
- effects/qglcolladafxeffect.h \
- effects/qglcolladafxeffectloader.h
-
-SOURCES += \
- qglflatcoloreffect.cpp \
- qglflattextureeffect.cpp \
- qgllitmaterialeffect.cpp \
- qgllittextureeffect.cpp \
- qglshaderprogrameffect.cpp \
- qglcolladafxeffect.cpp \
- qglcolladafxeffectfactory.cpp \
- qglcolladafxeffectloader.cpp
-
-PRIVATE_HEADERS += \
- qglflatcoloreffect_p.h \
- qglflattextureeffect_p.h \
- qgllitmaterialeffect_p.h \
- qgllittextureeffect_p.h \
- qglcolladafxeffect_p.h
diff --git a/src/threed/effects/qglcolladafxeffect.cpp b/src/threed/effects/qglcolladafxeffect.cpp
deleted file mode 100644
index 665c0ea7..00000000
--- a/src/threed/effects/qglcolladafxeffect.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 <QString>
-#include <QXmlStreamReader>
-#include <QFile>
-#include <QDebug>
-#include <QImage>
-#include "qgl.h"
-#include "qgltexture2d.h"
-#include "qglcolladafxeffect.h"
-#include "qglcolladafxeffect_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QGLColladaFxEffect::QGLColladaFxEffect() : QGLShaderProgramEffect()
- , d( new QGLColladaFxEffectPrivate )
-{
-}
-
-QGLColladaFxEffect::QGLColladaFxEffect(const QGLColladaFxEffect&) : QGLShaderProgramEffect()
-{
- Q_ASSERT(false);
-};
-
-
-QGLColladaFxEffect::~QGLColladaFxEffect()
-{
- delete d;
-}
-
-
-
-QGLColladaFxEffectPrivate::QGLColladaFxEffectPrivate() : id()
- , sid()
- , name()
- , emissiveTexture(0)
- , ambientTexture(0)
- , diffuseTexture(0)
- , specularTexture(0)
- , lighting(QGLColladaFxEffect::NoLighting)
- , material(0)
-{
- resetGlueSnippets();
-}
-
-
-
-QGLColladaFxEffectPrivate::~QGLColladaFxEffectPrivate()
-{
- delete emissiveTexture;
- emissiveTexture = 0;
- delete ambientTexture;
- ambientTexture = 0;
- delete diffuseTexture;
- diffuseTexture = 0;
- delete specularTexture;
- specularTexture = 0;
- delete material;
- material = 0;
-
-}
-
-
-
-inline void QGLColladaFxEffectPrivate::updateMaterialChannelSnippets(QString channelName, QGLTexture2D* texture, int* textureUnit, QColor fallbackColor)
-{
- QString qVariableName = QLatin1String("q") + channelName;
- if (texture != 0)
- {
- QString sourceVariableName = QLatin1String("texture") + channelName;
- QString texVariableName = QString(QLatin1String("texCoord%1")).arg(*textureUnit);
- // Take care of texture coordinates
- QString varyingSnippet = QString(QLatin1String("varying vec4 %1;")).arg(texVariableName);
- vertexShaderDeclarationSnippets.append(varyingSnippet);
- vertexShaderVariableNames.append(texVariableName);
- fragmentShaderDeclarationSnippets.append(varyingSnippet);
- fragmentShaderVariableNames.append(texVariableName);
-
- vertexShaderCodeSnippets.append(QString(QLatin1String("%1 = texCoords; // TODO: dynamically add tex attributes\n")).arg(texVariableName));
- vertexShaderVariableNames.append(texVariableName);
-
- // Declare the color variable in the fragment shader
- fragmentShaderDeclarationSnippets.append(QString(QLatin1String("lowp vec4 %1;")).arg(qVariableName));
- fragmentShaderVariableNames.append(qVariableName);
- fragmentShaderDeclarationSnippets.append(QString(QLatin1String("uniform sampler2D %1;")).arg(sourceVariableName));
- fragmentShaderVariableNames.append(sourceVariableName);
-
- // Assign a colour to the variable out of the appropriate sampler
- fragmentShaderCodeSnippets.append(QLatin1String(" mediump vec4 ") + qVariableName + QLatin1String(" = texture2D(") + sourceVariableName + QLatin1String(", ") + texVariableName + QLatin1String(".st);"));
- fragmentShaderVariableNames.append(qVariableName);
- // mediump? lowp?
-
- *textureUnit++;
- } else {
- fragmentShaderDeclarationSnippets.append(QString (QLatin1String("const vec4 %1 = vec4(%2, %3, %4, %5);")).arg( qVariableName).arg(fallbackColor.redF(), 0, 'f', 6).arg(fallbackColor.greenF(), 0, 'f', 6).arg(fallbackColor.blueF(), 0, 'f', 6).arg(fallbackColor.alphaF(), 0, 'f', 6 ));
- fragmentShaderVariableNames.append(qVariableName);
- }
-}
-
-
-
-inline void QGLColladaFxEffectPrivate::setTextureUniform(QGLShaderProgram *program, QGLPainter* painter, QString channelName, QGLTexture2D* texture, int* textureUnit, QColor fallbackColor)
-{
- QString qVariableName = QLatin1String("q") + channelName;
-
- if (texture != 0)
- {
- QString sourceVariableName = QLatin1String("texture") + channelName;
- QString texVariableName = QString(QLatin1String("texCoord%1")).arg(*textureUnit);
- painter->glActiveTexture(GL_TEXTURE0 + *textureUnit);
- texture->bind();
- program->setUniformValue(sourceVariableName.toAscii().data(), *textureUnit);
- }
- else
- {
- // It's just a const value, so set it that way in the fragment shader.
- program->setUniformValue(qVariableName.toAscii().data(), fallbackColor);
- }
-}
-
-
-
-void QGLColladaFxEffect::update(QGLPainter *painter, QGLPainter::Updates updates)
-{
- QGLShaderProgramEffect::update(painter, updates);
-
- if (updates && QGLPainter::UpdateMaterials)
- {
-
- if (program() == 0)
- {
- qWarning() << "no program in QGLColladaFxEffect::update()";
- return;
- }
-
- // Start from texture unit 1 so as not to stomp a texture set on the
- // painter.
- int textureUnit = 1;
- d->setTextureUniform(
- program(), painter, QLatin1String("Emissive"), d->emissiveTexture,
- &textureUnit,
- material() ? material()->emittedLight() : QColor());
-
- d->setTextureUniform(
- program(), painter, QLatin1String("Ambient"), d->ambientTexture, &textureUnit,
- material() ? material()->ambientColor() : QColor());
-
- d->setTextureUniform(
- program(), painter, QLatin1String("Diffuse"), d->diffuseTexture, &textureUnit,
- material() ? material()->diffuseColor() : QColor());
-
- d->setTextureUniform(
- program(), painter, QLatin1String("Specular"), d->specularTexture,
- &textureUnit,
- material() ? material()->specularColor() : QColor());
- }
-}
-
-
-
-void QGLColladaFxEffect::setId(QString id)
-{
- d->id = id;
-}
-
-
-
-QString QGLColladaFxEffect::id()
-{
- return d->id;
-}
-
-
-
-void QGLColladaFxEffect::setSid(QString sid)
-{
- d->sid = sid;
-}
-
-
-
-void QGLColladaFxEffectPrivate::addMaterialChannelsToShaderSnippets(const QGLMaterial *material)
-{
- int textureUnit = 1;
-
- updateMaterialChannelSnippets(QLatin1String("Emissive"), emissiveTexture, &textureUnit, material->emittedLight());
- updateMaterialChannelSnippets(QLatin1String("Ambient"), ambientTexture, &textureUnit, material->ambientColor());
- updateMaterialChannelSnippets(QLatin1String("Diffuse"), diffuseTexture, &textureUnit, material->diffuseColor());
- updateMaterialChannelSnippets(QLatin1String("Specular"), specularTexture, &textureUnit, material->specularColor());
-}
-
-
-
-void QGLColladaFxEffect::addBlinnPhongLighting()
-{
- d->addMaterialChannelsToShaderSnippets(material());
-
- // Fragment shader declarations:
- d->fragmentShaderDeclarationSnippets.append(QLatin1String("uniform mediump sampler2D texture0;"));
- d->fragmentShaderVariableNames.append(QLatin1String("texture0"));
- d->fragmentShaderDeclarationSnippets.append(QLatin1String("varying highp vec4 qt_TexCoord0;"));
- d->fragmentShaderVariableNames.append(QLatin1String("qt_TexCoord0"));
-
- // Fragment Shader code
- d->fragmentShaderCodeSnippets.append(QLatin1String(
- " vec4 specularComponent = vec4( 0.0, 0.0, 0.0, 0.0 );\n"\
- " if (intensity > 0.0)\n"\
- " {\n"\
- " float specularIntensity = max( dot(perPixelNormal, qHalfVector), 0.0 );\n"\
- " if (specularIntensity > 0.0)\n"\
- " specularComponent = qSpecular * pow(specularIntensity, shininess);\n"\
- " }\n"));
- d->fragmentShaderVariableNames.append(QLatin1String("lighting"));
-
-
- // Replace the "end glue" to set colour from lighting
- d->fragmentShaderEndGlueSnippet = QLatin1String(
- " vec4 texture0Color = texture2D(texture0, qt_TexCoord0.st);\n"\
- " vec4 diffuseColor = qDiffuse;\n"\
- " vec4 lightingColor = qAmbient + diffuseColor * intensity + specularComponent;\n"\
- " vec4 texturedColor = vec4(lightingColor.xyz * (1.0 - texture0Color.a)\n"\
- "+ (texture0Color.xyz + specularComponent.rgb) * texture0Color.a, lightingColor.a);\n"\
- " gl_FragColor = texturedColor;\n"\
- "}");
- generateShaders();
-}
-
-
-
-void QGLColladaFxEffect::generateShaders()
-{
- if (vertexShader().isEmpty())
- {
- QString shader =
- d->vertexShaderDeclarationSnippets.join(QLatin1String("\n"))
- + QLatin1String("\n") + d->vertexShaderMainGlueSnippet
- + d->vertexShaderCodeSnippets.join(QLatin1String("\n"))
- + QLatin1String("\n") + d->vertexShaderEndGlueSnippet;
- setVertexShader(shader.toLatin1());
- }
-
- if (fragmentShader().isEmpty())
- {
- QString shader =
- d->fragmentShaderDeclarationSnippets.join(QLatin1String("\n"))
- + QLatin1String("\n") + d->fragmentShaderMainGlueSnippet
- + d->fragmentShaderCodeSnippets.join(QLatin1String("\n"))
- + QLatin1String("\n") + d->fragmentShaderEndGlueSnippet;
- setFragmentShader(shader.toLatin1());
- }
-}
-
-
-
-void QGLColladaFxEffectPrivate::resetGlueSnippets()
-{
- vertexShaderMainGlueSnippet = QLatin1String(
- "attribute highp vec4 vertex;\n"\
- "attribute highp vec4 normal;\n"\
- "attribute highp vec4 texCoords;\n"\
- "uniform highp mat4 matrix;\n"\
- "uniform highp mat3 qt_NormalMatrix;\n"\
- "varying mediump vec3 qNormal;\n"\
- "varying mediump vec3 qLightDirection;\n"\
- "varying mediump vec3 qHalfVector;\n"\
- "uniform mediump vec3 pli; // Position of the light\n"\
- "varying highp vec4 qt_TexCoord0; // TEMP\n" /* Got to get rid of this*/\
- "\n"\
- "void qLightVertex(vec4 vertex, vec3 normal)\n"\
- "{\n"\
- " vec3 toEye;\n"\
- " qLightDirection = normalize(pli);\n"\
- " toEye = vec3(0, 0, 1); // assume viewer at infinity\n"\
- " qHalfVector = normalize(qLightDirection + toEye);\n"\
- "}\n"\
- "\n"\
- "void main(void)\n"\
- "{\n"\
- " qNormal = normalize(qt_NormalMatrix * vec3(normal));\n"\
- " qLightVertex(vertex, qNormal);\n"\
- " qt_TexCoord0 = texCoords;\n"\
- );
-
- vertexShaderEndGlueSnippet = QLatin1String (
- " gl_Position = matrix * vertex;\n"\
- "}\n");
-
-
- fragmentShaderEndGlueSnippet = QLatin1String(
- " gl_FragColor = color;\n"\
- "}\n"
- );
-
- fragmentShaderMainGlueSnippet = QLatin1String(
- "varying mediump vec3 qNormal;\n"\
- "varying mediump vec3 qLightDirection;\n"\
- "varying mediump vec3 qHalfVector;\n"\
- "uniform float shininess;\n"\
- "uniform vec4 color;\n"\
- "vec3 perPixelNormal;"
- "\n"\
- "void main()\n"\
- "{\n"\
- " perPixelNormal = normalize(qNormal);\n"\
- " float intensity = max(dot(perPixelNormal, qLightDirection), 0.0);\n"
- );
-}
-
-
-
-QString QGLColladaFxEffect::sid()
-{
- return d->sid;
-}
-
-
-
-QGLTexture2D* QGLColladaFxEffect::diffuseTexture()
-{
- return d->diffuseTexture;
-}
-
-
-void QGLColladaFxEffect::setLighting(int lighting)
-{
- d->lighting = lighting;
-}
-
-int QGLColladaFxEffect::lighting()
-{
- return d->lighting;
-}
-
-/*!
- Sets this effect to use \a newMaterial. If \a newMaterial is 0, sets this
- effect to have no material, and instead use whatever material is set
- on the QGLPainter.
-
- \sa QGLPainter, material()
-*/
-void QGLColladaFxEffect::setMaterial(QGLMaterial* newMaterial)
-{
- d->material = newMaterial;
-}
-
-/*!
- Returns a pointer to the material of this effect. If the effect has no material,
- this function returns 0;
-*/
-QGLMaterial* QGLColladaFxEffect::material()
-{
- return d->material;
-}
-
-/*!
- Returns true if the effect is currently active (applied to a QGLPainter)
- and false if it is not.
- */
-bool QGLColladaFxEffect::isActive()
-{
- return d->currentlyActive;
-}
-
-void QGLColladaFxEffect::setActive(QGLPainter *painter, bool flag)
-{
- d->currentlyActive = flag && !vertexShader().isEmpty() &&
- !fragmentShader().isEmpty();
- QGLShaderProgramEffect::setActive(painter, d->currentlyActive);
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglcolladafxeffect.h b/src/threed/effects/qglcolladafxeffect.h
deleted file mode 100644
index 9486ec04..00000000
--- a/src/threed/effects/qglcolladafxeffect.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCOLLADAEFFECT_H
-#define QGLCOLLADAEFFECT_H
-
-#include <QStack>
-#include <QList>
-#include <QGLShaderProgram>
-#include "qglshaderprogrameffect.h"
-
-QT_BEGIN_NAMESPACE
-
-class QXmlStreamReader;
-class QGLColladaParam;
-class QGLColladaFxEffectPrivate;
-
-class Q_QT3D_EXPORT QGLColladaFxEffect : public QGLShaderProgramEffect
-{
- friend class QGLColladaFxEffectFactory;
-
-public:
- enum Lighting
- {
- NoLighting,
- BlinnLighting,
- PhongLighting,
- ConstantLighting,
- LambertLighting,
- CustomLighting
- };
-
- QGLColladaFxEffect();
- ~QGLColladaFxEffect();
- void update(QGLPainter *painter, QGLPainter::Updates updates);
- void generateShaders();
- void addBlinnPhongLighting();
-
- void setId(QString);
- void setSid(QString);
- QString id();
- QString sid();
-
- void setLighting(int lighting);
- int lighting();
- void setMaterial(QGLMaterial* newMaterial);
- QGLMaterial* material();
-
- QGLTexture2D* diffuseTexture();
-
- bool isActive();
- void setActive(QGLPainter *painter, bool flag);
-private:
- QGLColladaFxEffect(const QGLColladaFxEffect&);
- QGLColladaFxEffectPrivate* d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLCOLLADAEFFECT_H
diff --git a/src/threed/effects/qglcolladafxeffect_p.h b/src/threed/effects/qglcolladafxeffect_p.h
deleted file mode 100644
index cf7dae2f..00000000
--- a/src/threed/effects/qglcolladafxeffect_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCOLLADAFXEFFECT_P_H
-#define QGLCOLLADAFXEFFECT_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.
-//
-
-#include <QString>
-#include <QMap>
-#include <QColor>
-#include "qgltexture2d.h"
-#include "qglcolladafxeffect.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLPainter;
-class QGLShaderProgram;
-class QGLMaterial;
-
-class QGLColladaFxEffectPrivate
-{
- friend class QGLColladaFxEffectFactory;
-public:
- QGLColladaFxEffectPrivate();
- ~QGLColladaFxEffectPrivate();
-
- void addMaterialChannelsToShaderSnippets(const QGLMaterial *material);
- void resetGlueSnippets();
- void setTextureUniform(QGLShaderProgram *program, QGLPainter* painter, QString channelName, QGLTexture2D* texture, int* textureUnit, QColor fallbackColor);
- void updateMaterialChannelSnippets(QString channelName, QGLTexture2D* texture, int* textureUnit, QColor fallbackColor);
-
- QString id;
- QString sid;
- QString name;
-
- // The spec allows for 3D textures as well, but for now only 2D is
- // supported
- QGLTexture2D* emissiveTexture;
- QGLTexture2D* ambientTexture;
- QGLTexture2D* diffuseTexture;
- QGLTexture2D* specularTexture;
- int lighting;
- QGLMaterial* material;
-
- QStringList vertexShaderCodeSnippets;
- QStringList vertexShaderDeclarationSnippets;
- QStringList vertexShaderVariableNames;
-
- QStringList fragmentShaderCodeSnippets;
- QStringList fragmentShaderDeclarationSnippets;
- QStringList fragmentShaderVariableNames;
-
- QString vertexShaderEndGlueSnippet;
- QString vertexShaderMainGlueSnippet;
- QString fragmentShaderEndGlueSnippet;
- QString fragmentShaderMainGlueSnippet;
-
- bool currentlyActive;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLCOLLADAFXEFFECT_P_H
diff --git a/src/threed/effects/qglcolladafxeffectfactory.cpp b/src/threed/effects/qglcolladafxeffectfactory.cpp
deleted file mode 100644
index 192c2dc0..00000000
--- a/src/threed/effects/qglcolladafxeffectfactory.cpp
+++ /dev/null
@@ -1,1694 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 <QVector>
-#include <QFile>
-#include <QFileInfo>
-#include <QTime>
-#include <QDir>
-#include "qgltexture2d.h"
-#include "qgl.h"
-
-#include "qglcolladafxeffect.h"
-#include "qglcolladafxeffectfactory.h"
-//#include "qglcolladafxeffectfactory_p.h"
-#include "qglcolladafxeffect_p.h"
-
-QT_BEGIN_NAMESPACE
-
-// The QGLColladaFxFactory class creates a list of QGLColladaFx objects from
-// COLLADA FX information according to the 1.4.1 March 2008 Release from
-// http://www.khronos.org/collada/
-
-//#define DEBUG_QGL_COLLADA_PARSING
-//#define DEBUG_MATERIALS
-
-#define INDENT_SIZE 4
-
-static int QGLColladaIndentLevel = 0;
-
-// This is a simple RAII helper class to conveniently indent across
-// various functions when building up the collada elements.
-// Instantiate an indent to increment the indent level with that scope.
-// add an indent object to the beginning of a string to indent it
-// the correct amount.
-class Indent
-{
-public:
- static int currentIndent() { return QGLColladaIndentLevel; };
- Indent()
- {
- ++QGLColladaIndentLevel;
- };
- ~Indent()
- {
- --QGLColladaIndentLevel;
- }
-};
-
-QString operator +(Indent&, QString string)
-{
- return QString(QGLColladaIndentLevel * INDENT_SIZE, QLatin1Char(' ')) + string;
-}
-
-QString operator +(char c, Indent&)
-{
- return QLatin1Char(c) + QString(QGLColladaIndentLevel * INDENT_SIZE, QLatin1Char(' '));
-}
-
-// xml convenience function - find the first end tag with the given tagname
-// Note that this is not as smart as xml.skipCurrentElement(), and does
-// not handle the case where (grand)children node share tagName
-// With this caveat, can be called from within any (grand)child node.
-static inline void findEndTag( QXmlStreamReader& xml, QString tagName )
-{
- while ( !xml.atEnd() && !( xml.tokenType() == xml.EndElement && xml.name() == tagName))
- {
- xml.readNext();
- }
-}
-
-
-
-/*!
- \internal
- Convenience function to find parameters in \a resultState that have an id,
- sid, or name that is equal to \a stringToMatch
- Note that this using this is not in line with the Collada specification,
- and that non-unique sids will always return the last parameter parsed.
- */
-static inline QVariant findParameterVariant(ResultState* resultState, QString stringToMatch)
-{
- QVariant result = resultState->paramSids.value(stringToMatch);
-
- if ( result.isNull() )
- result = resultState->paramIds.value(stringToMatch);
-
- if ( result.isNull() )
- result = resultState->paramNames.value(stringToMatch);
-
- return result;
-}
-
-/*!
- Parse a collada 1.4 or 1.5 .dae file \a fileName, find the effects in the
- library_effects element, and convert these into a list of QGLColladaFxEffect objects
- suitable for use with Qt3D. Specific effects can be identified out of
- this list using their sid.
-
- This is the only function intended to be called from outside this class, e.g.:
-
- QList<QGLColladaFxEffect*> colladaEffects = QGLColladaFxEffectFactory::loadEffectsFromFile("myColladaFile.dae");
-
- \sa QGLColladaFxEffect
-*/
-QList<QGLColladaFxEffect*> QGLColladaFxEffectFactory::loadEffectsFromFile( const QString& fileName )
-{
- QFile file( fileName );
- if ( !file.open( QIODevice::ReadOnly ))
- {
- qWarning() << "Warning: QGLColladaFxEffect failed to open file" << fileName;
- return QList<QGLColladaFxEffect*>();
- }
-
-
- QXmlStreamReader xml;
- xml.setDevice( &file );
- if (xml.tokenType() == QXmlStreamReader::Invalid)
- file.readLine();
- xml.setDevice( &file );
-
- QFileInfo fileInfo(file);
-
- return loadEffectsFromXml( xml, fileInfo.dir() );
-}
-
-
-
-QString QGLColladaFxEffectFactory::exportEffect(QGLColladaFxEffect *effect, QString effectId, QString techniqueSid)
-{
- QStringList result;
-
- result += QLatin1String("<?xml version=\"1.0\"?>");
-
- result += QLatin1String("<COLLADA "\
- "xmlns=\"http://www.collada.org/2005/11/COLLADASchema\" version=\"1.5.0\" >");
-
- {
- Indent indent;
- result += indent + QLatin1String("<asset>");
- {
- Indent indent;
- QDateTime time = QDateTime::currentDateTime();
- result += indent + QLatin1String("<created>") + time.toString(Qt::ISODate) + QLatin1String("</created>");
- result += indent + QLatin1String("<modified>") + time.toString(Qt::ISODate) + QLatin1String("</modified>");
- }
- result += indent + QLatin1String("</asset>");
-
- result += indent + QLatin1String("<library_effects>");
- {
- Indent indent;
- result += indent + QLatin1String("<effect id=\"") + effectId + QLatin1String("\">");
- result += glslProfileFromEffect(effect, techniqueSid);
- result += indent + QLatin1String("</effect>");
- }
- result += indent + QLatin1String("</library_effects>");
- result += QLatin1String("</COLLADA>");
- return result.join(QLatin1String("\n"));
- }
-}
-
-
-/*!
- \internal
- parse the top level \a xml from a .dae file and process the library_effects elements therein.
-*/
-QList<QGLColladaFxEffect*> QGLColladaFxEffectFactory::loadEffectsFromXml( QXmlStreamReader& xml, QDir homeDirectory )
-{
- ResultState resultState;
- resultState.sourceDir = homeDirectory;
- QList<QGLColladaFxEffect*> result;
-
- while ( !xml.atEnd() ) {
- xml.readNextStartElement();
- if ( xml.name() == "library_effects" ) {
- result += processLibraryEffectsElement( xml , &resultState );
- } else if (xml.name() == "library_images")
- {
- processLibraryImagesElement( xml, &resultState );
- }
- }
-
- // Try and resolve outstanding textures
- QList<QGLTexture2D*> unresolvedTexturePointers = resultState.unresolvedTexture2Ds.keys();
- for (int i = 0; i < unresolvedTexturePointers.count(); i++)
- {
- QGLTexture2D* texture = unresolvedTexturePointers[i];
- QString parameterName = resultState.unresolvedTexture2Ds.value(texture);
- resolveTexture2DImage(texture, &resultState, parameterName);
- }
- return result;
-}
-
-
-
-QGLColladaParam::~QGLColladaParam()
-{
-
-}
-
-
-
-/*!
- \internal
-*/
-int QGLColladaParam::type()
-{
- return mType;
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaParam::sid()
-{
- return mSid;
-}
-
-
-
-/*!
- \internal
-*/
-QVector<float> QGLColladaParam::value() {
- return mValue;
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaParam::QGLColladaParam(QString sid, int type) : mSid(sid)
- , mType(type)
-{
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaParam::id()
-{
- return mId;
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaParam::typeString(int type)
-{
- const char* typeStringArray[] = {
- "UnkownType",
- "Sampler2DType",
- "Texture2DType",
- "SurfaceType",
- "ImageType"};
-
- if (type >= UserDefinedType)
- return QLatin1String("UserDefinedType");
- else if ( type < 0 || type > ImageType)
- return QLatin1String("Unrecognized Type");
- else
- return QLatin1String(typeStringArray[type]);
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaTextureParam::QGLColladaTextureParam(QString sid, QGLTexture2D* texture) : QGLColladaParam(sid, Texture2DType)
-{
- mTexture = texture;
-}
-
-
-
-/*!
- \internal
-*/
-QGLTexture2D* QGLColladaTextureParam::texture()
-{
- Q_ASSERT( mType == Sampler2DType || mType == Texture2DType);
- return mTexture;
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaTextureParam::samplerSid()
-{
- return sampler2DSid;
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaFxEffectFactory::QGLColladaFxEffectFactory()
-{
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaSampler2DParam::QGLColladaSampler2DParam(QString sid, QGLTexture2D* texture)
- : QGLColladaParam(sid, QGLColladaParam::Sampler2DType)
- , mTexture(texture)
-{
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaSampler2DParam::QGLColladaSampler2DParam(QString sid, QString sourceSid)
- : QGLColladaParam(sid, QGLColladaParam::Sampler2DType)
- , mTexture(0)
- , mSourceSid(sourceSid)
-{
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaSampler2DParam::sourceSid()
-{
- return mSourceSid;
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaSurfaceParam::QGLColladaSurfaceParam(QString sid) : QGLColladaParam(sid, QGLColladaParam::SurfaceType)
- , mInitFrom()
- , mFormat()
- , mFormatHint()
- , mSize()
- , mSizeVector( 3, 0 )
- , mViewportRatio( 1.0, 1.0 )
- , mMipLevels( 0 )
- , mMipMapGenerate( false )
- , mExtra()
- , mGenerator()
-{
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaImageParam::QGLColladaImageParam(QString sid, QImage image)
- : QGLColladaParam(sid, QGLColladaParam::ImageType)
- , mImage(image)
-{
-}
-
-
-
-/*!
- \internal
-*/
-QImage QGLColladaImageParam::image()
-{
- return mImage;
-}
-
-
-
-/*!
- \internal
-*/
-QString QGLColladaImageParam::name()
-{
- return mName;
-}
-
-
-
-/*!
- \internal
-*/
-QGLColladaSurfaceParam* QGLColladaFxEffectFactory::processSurfaceElement( QXmlStreamReader& xml , ResultState* resultState, QString passedInSid)
-{
- Q_UNUSED(resultState);
- QXmlStreamAttributes attributes = xml.attributes();
- QString surfaceSid = attributes.value(QLatin1String("sid")).toString();
- // Surfaces are the only children of a newparam, but don't have their own
- // sids. For simplicity, use the parent's sid.
-
- if (surfaceSid.isEmpty() && !passedInSid.isEmpty())
- surfaceSid = passedInSid;
- QGLColladaSurfaceParam* result = new QGLColladaSurfaceParam( surfaceSid );
- xml.readNextStartElement();
- if ( xml.name().toString().left(4) == QLatin1String("init") )
- {
- if (xml.name().toString() != QLatin1String("init_from"))
- qWarning() << "Warning: only ""init_from"" supported in surface element ( line:" << xml.lineNumber() << ")";
- QString init_from = xml.readElementText();
- result->mInitFrom = init_from;
- resultState->paramSids[surfaceSid] = init_from;
- }
- return result;
-}
-
-
-
-/*!
- \internal
- Processes a list of floating point numbers. If the list contains only 1
- element, a QVariant<float> is returned. If the list containst 2, 3 or 4
- elements, they are converted into a QVariant containing a QVector2D,
- QVector3D, or QVector4D respectively.
- If the list containst more elements than that, they are returned as a
- QArray<float>.
-
-*/
-QVariant QGLColladaFxEffectFactory::processFloatList( QXmlStreamReader& xml )
-{
- QArray<float> floats;
- QString elementString = xml.readElementText();
- QStringList list = elementString.split( QRegExp( QLatin1String("\\s+") ), QString::SkipEmptyParts );
- bool ok;
- float f;
- foreach ( QString string, list )
- {
- f = string.toFloat( &ok );
- if ( ok )
- floats.append(string.toFloat());
- else
- {
- qWarning() << "Warning: malformed float ( line" << xml.lineNumber() << ")";
- }
- }
-
- switch(floats.count())
- {
- case 0:
- return QVariant();
- // no break necessary
- case 1:
- return QVariant(floats[0]);
- // no break necessary
- case 2:
- return QVariant(QVector2D(floats[0], floats[1]));
- // no break necessary
- case 3:
- return QVariant(QVector3D(floats[0], floats[1], floats[2]));
- // no break necessary
- case 4:
- return QVariant(QVector4D(floats[0], floats[1], floats[2], floats[3]));
- // no break necessary
- default:
- {
- QVariant result;
- result.setValue(floats);
- return result;
- }
- }
- // Function should always return out of switch statement
-}
-
-
-
-/*!
- \internal
-*/
-void QGLColladaFxEffectFactory::processSampler2DElement( QXmlStreamReader& xml, ResultState* resultState, QString passedInSid )
-{
- Q_UNUSED(resultState);
- QXmlStreamAttributes attributes = xml.attributes();
- QString sid = attributes.value(QLatin1String("sid")).toString();
- if (sid.isEmpty() && !passedInSid.isEmpty())
- {
- sid = passedInSid;
- }
-
- xml.readNextStartElement();
- if ( xml.name() == QLatin1String("source"))
- {
- // Collada 1.4 Spec
- QString sourceSurfaceSid = xml.readElementText().trimmed();
- resultState->paramSids[sid] = sourceSurfaceSid;
- }
-
- if ( xml.name() == QLatin1String("instance_image") )
- {
- // Collada 1.5 Spec
- qWarning() << "collada 1.5 sampler elements not supported ( line:" << xml.lineNumber() << ")";
- }
- // exit cleanly, just in case.
- findEndTag( xml, QLatin1String("sampler2D"));
- return;
-}
-
-
-
-/*!
- \internal
- Parses and consumes a color collada element from \a xml.
-*/
-QColor QGLColladaFxEffectFactory::processColorElement( QXmlStreamReader& xml )
-{
- QVariant floatList = processFloatList( xml );
-
- QColor result( 0, 0, 0, 255 );
- if (floatList.type() == QVariant::Vector3D)
- {
- QVector3D vector3D = floatList.value<QVector3D>();
- if ( !vector3D.isNull())
- {
- result.setRgbF( vector3D.x()
- , vector3D.y()
- , vector3D.z()
- , 1.0 );
- return result;
- }
- }
- else if (floatList.type() == QVariant::Vector4D)
- {
- QVector4D vector4D = floatList.value<QVector4D>();
- if (!vector4D.isNull())
- {
- result.setRgbF( vector4D.x()
- , vector4D.y()
- , vector4D.z()
- , vector4D.w() );
- return result;
- }
- }
- qWarning() << "Warning: Malformed color element ( line" << xml.lineNumber() << ")";
- return result;
-}
-
-
-
-/*!
- \internal
- Parses and consumes an fx_common_color_or_texture_type collada element from \a xml.
-*/
-QVariant QGLColladaFxEffectFactory::processColorOrTextureElement( QXmlStreamReader& xml )
-{
- if ( xml.name() == QLatin1String("color"))
- {
- return processColorElement( xml );
- } else if ( xml.name() == QLatin1String("texture") )
- {
- qWarning() << "Warning: texture element not supported ( line" << xml.lineNumber()<<")";
- } else
- {
- qWarning() << "Color or Texture expected ( line" << xml.lineNumber() << ")";
- }
- xml.skipCurrentElement();
- return( QColor( 0, 0, 0,255 ));
-}
-
-
-
-/*!
- \internal
- Parses an fx_common_float_or_param_type collada element from \a xml.
- Always consumes the element.
-*/
-float QGLColladaFxEffectFactory::processParamOrFloatElement( QXmlStreamReader& xml )
-{
- if ( xml.name() == QLatin1String("param") )
- {
- qWarning() << "Warning: params not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- return 0.0;
- } else
- {
- return xml.readElementText().toFloat();
- }
-}
-
-
-
-/*!
- Parses and consumes a library_images collada element pointed to by \a xml,
- and pushes any images found onto the \a resultState for use in resolving
- elements later.
-*/
-void QGLColladaFxEffectFactory::processLibraryImagesElement( QXmlStreamReader& xml, ResultState* resultState )
-{
- xml.readNextStartElement();
-
- if ( xml.name() == QLatin1String("asset") )
- {
- qWarning() << "Warning: effect asset handling not supported in library_images element ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("image") && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- processImageElement( xml , resultState );
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-}
-
-
-/*!
- \internal
-*/
-QList<QGLColladaFxEffect*> QGLColladaFxEffectFactory::processLibraryEffectsElement( QXmlStreamReader& xml, ResultState* resultState )
-{
- QList<QGLColladaFxEffect*> result;
- // A collada library_effects is
- // 0 or 1 <asset>
- // 1 or more <effect>,
- // 0 or more <extra>;
- xml.readNextStartElement();
-
- if ( xml.name() == QLatin1String("asset") )
- {
- qWarning() << "Warning: effect asset handling not supported in effects library ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("effect") && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- result += processEffectElement( xml , resultState );
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("extra") )
- {
- qWarning() << "Warning: extra element not handled in effects library ( line" << xml.lineNumber() << ")";
- xml.readNextStartElement();
- }
-
- // be sure to exit cleanly
- findEndTag(xml, QLatin1String("library_effects"));
- return result;
-}
-
-
-
-/*!
- \internal
- Parses and consumes an effect element from \a xml.
-*/
-QList<QGLColladaFxEffect*> QGLColladaFxEffectFactory::processEffectElement( QXmlStreamReader& xml, ResultState* resultState )
-{
- // An effect element is:
- // 0 or 1 <annotate>
- // 0 or more newparam
- // 1 or more profile ( either <profile_BRIDGE>, <profile_CG>, <profile_GLES>, <profile_GLES2>, <profile_GLSL>, or <profile_COMMON>
- // 0 or more <extra>
-
- QList<QGLColladaFxEffect*> result;
- xml.readNextStartElement();
-
- if ( xml.name() == QLatin1String("annotate") )
- {
- qWarning() << "effect annotation not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("newparam") && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- processNewparamElement( xml , resultState );
- xml.readNextStartElement();
- }
-
- // find any of the profile_* elements defined in the spec
- QRegExp profileRegExp( QLatin1String("profile_(BRIDGE|CG|GLES2?|GLSL|COMMON)") );
- while ( profileRegExp.indexIn( xml.name().toString() ) == 0 && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- result += processProfileElement( xml, resultState );
- xml.readNextStartElement();
- }
-
- findEndTag(xml, QLatin1String("effect"));
- return result;
-}
-
-
-
-/*!
- \internal
-*/
-QList<QGLColladaFxEffect*> QGLColladaFxEffectFactory::processProfileElement( QXmlStreamReader& xml, ResultState* resultState )
-{
- // A profile_GLES2 element is:
- // 0 or 1 <asset>
- // 0 or more <code> or <include>
- // 0 or more <newparam>
- // 1 or more <technique>
-
- // A profile_GLSL element is:
- // 0 or 1 <asset>
- // 0 or more <code>
- // 0 or more <include>
- // 0 or more <newparam>
- // 1 or more <technique>
- // 0 or more <extra>
-
- // A profile_COMMON element is
- // an optional id element
- // 0 or 1 <asset>
- // 0 or more <newparam>
- // 1 <technique>
- // 0 or more <extra>
-
- // Note: techniques need to be handled differently for different profiles
-
- QString rootNodeString = xml.name().toString();
- QList<QGLColladaFxEffect*> result;
-
- xml.readNextStartElement();
- if ( xml.name() == QLatin1String("asset") )
- {
- qWarning() << "Warning: asset element not supported in " << rootNodeString << "elements ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if (rootNodeString == QLatin1String("profile_GLSL"))
- {
- while ( xml.name() == QLatin1String("code") )
- {
- QString codeSid = xml.attributes().value(QLatin1String("sid")).toString();
- QString codeText = xml.readElementText();
- resultState->paramSids[codeSid] = codeText;
-
- findEndTag(xml, QLatin1String("code"));
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("include") )
- {
- QString includeSid = xml.attributes().value(QLatin1String("sid")).toString();
- QString includeUrl = xml.attributes().value(QLatin1String("url")).toString();
-
- // create an include param?
- qWarning() << "Warning: include element not supported in " << rootNodeString << "elements ( line" << xml.lineNumber() << ")";
-
- findEndTag(xml, QLatin1String("include"));
- xml.readNextStartElement();
- }
-
- }
-
- while ( xml.tokenType() == QXmlStreamReader::StartElement &&
- ( xml.name() == QLatin1String("newparam") || xml.name() == QLatin1String("image") ))
- {
- if ( xml.name() == QLatin1String("newparam") )
- processNewparamElement( xml , resultState );
- else if ( xml.name() == QLatin1String("image") )
- processImageElement( xml , resultState );
-
- xml.readNextStartElement();
- }
-
-
- while ( xml.name() == QLatin1String("technique") )
- {
- result.append(
- processTechniqueElement( xml, resultState, rootNodeString ));
- xml.readNextStartElement();
- // only 1 technique in profile_COMMON
- if ( rootNodeString == QLatin1String("profile_COMMON"))
- {
- break;
- }
- };
-
- while ( xml.name() == QLatin1String("extra") )
- {
- qWarning() << "extra elements currently not supported in " << rootNodeString << "elements ( line" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("extra") );
- xml.readNextStartElement();
- };
-
- findEndTag( xml, rootNodeString );
- return result;
-}
-
-
-QGLColladaParam* QGLColladaFxEffectFactory::processPassElement( QXmlStreamReader& xml, ResultState* resultState, QGLColladaFxEffect* effect )
-{
- QGLColladaParam* result = 0;
- // a profile_GLSL pass is:
- // 0 or 1 <annotate>
- // 0 or 1 <states>
- // 0 or 1 <program> (CG, GLES2 or GLSL only)
- // 0 or 1 <evaluate>
- // 0 or 1 <extra>
-
- xml.readNextStartElement();
-
- if ( xml.name() == QLatin1String("annotate") )
- {
- qWarning() << "Warning: annotate element not supported ( line" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("annotate") );
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("states") )
- {
- qWarning() << "Warning: states element not supported ( line" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("states") );
- xml.readNextStartElement();
- }
-
- // 0 or 1 <program> (CG, GLES2 or GLSL only)
- if ( xml.name() == QLatin1String("program") )
- {
- processProgramElement( xml, resultState, effect );
- findEndTag( xml, QLatin1String("program") );
- xml.readNextStartElement();
- }
-
- // 0 or 1 <evaluate>
- if ( xml.name() == QLatin1String("evaluate") )
- {
- qWarning() << "Warning: evaluate element not supported ( line" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("evaluate") );
- xml.readNextStartElement();
- }
-
- // 0 or more <extra>
- while ( xml.name() == QLatin1String("extra") )
- {
- qWarning() << "Warning: extra element not supported ( line" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("extra") );
- xml.readNextStartElement();
- }
-
- findEndTag( xml, QLatin1String("pass"));
- return result;
-}
-
-QGLColladaFxEffect* QGLColladaFxEffectFactory::processTechniqueElement( QXmlStreamReader& xml, ResultState* resultState, QString &profileName )
-{
- // A 1.4 technique is:
- // 0 or 1 <asset>
- // 0 or more <newparam> or <image> (in any order)
- // 0 or more of <constant>, <lambert>, <phong>, <blinn>
- // 0 or more <extra>
-
- // A 1.5 profile_COMMON technique is:
- // 0 or 1 <asset>
- // exactly 1 of <blinn>, <constant>, <lambert>, or <phong>
- // 0 or more <extra>
-
- // a profile_GLSL technique is:
- // 0 or 1 <asset>
- // 0 or more <annotate>
- // 1 or more <pass>
- // 0 or more <extra>
-
- QGLColladaFxEffect* effect = new QGLColladaFxEffect();
-
- QXmlStreamAttributes attributes = xml.attributes();
- effect->setSid( attributes.value( QLatin1String("sid") ).toString() );
- QStringRef id = attributes.value( QLatin1String("id") );
- Q_UNUSED( id );
-
- xml.readNextStartElement();
-
- if ( xml.name() == QLatin1String("asset") )
- {
- qWarning() << "Warning: asset element not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("annotate") && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- qWarning() << "Warning: annotate element not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- // Collada specifies exactly one of blinn, lambert, constant or phong
- // If the effect is malformed, default QGLMaterial will be used.
- QGLMaterial* material = new QGLMaterial;
-
- if ( profileName == QLatin1String("profile_COMMON") &&
- (xml.name() == QLatin1String("blinn") || xml.name() == QLatin1String("phong") ||
- xml.name() == QLatin1String("constant") || xml.name() == QLatin1String("lambert")) )
- {
- if ( xml.name() == QLatin1String("blinn") )
- {
- effect->setLighting( QGLColladaFxEffect::BlinnLighting );
- } else if ( xml.name() == QLatin1String("phong") ) {
- effect->setLighting( QGLColladaFxEffect::PhongLighting );
- } else if ( xml.name() == QLatin1String("constant") ) {
- effect->setLighting( QGLColladaFxEffect::ConstantLighting );
- } else if ( xml.name() == QLatin1String("lambert") ) {
- effect->setLighting( QGLColladaFxEffect::LambertLighting );
- }
-
- // TODO: get appropriate shader fragments for the specified lighting models
- if ( xml.readNextStartElement() )
- {
- // a blinn element is 0 or 1 of each of:
- // <emission>
- // <diffuse>
- // <specular>
- // <shininess>
- // <reflectivity>
- // <transparent>
- // <transparency>
- // <index_of_refraction>
-
- if ( xml.name() == QLatin1String("emission") )
- {
- if ( xml.readNextStartElement() )
- {
- // handle color or texture element:
- if (xml.name() == QLatin1String("color"))
- {
- material->setEmittedLight( processColorElement( xml ));
-#ifdef DEBUG_MATERIALS
- qDebug() << "set emitted light to " << material->emittedLight();
-#endif
- }
- else if ( xml.name() == QLatin1String("texture"))
- {
- effect->d->emissiveTexture = processTextureElement( xml, resultState );
-#ifdef DEBUG_MATERIALS
- qDebug() << "set emissive texture to " << effect->d->emissiveTexture;
-#endif
- } else if ( xml.name() == QLatin1String("param"))
- {
- qWarning() << "params not supported in lighting elements ( line" << xml.lineNumber() << ")";
- }
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("ambient") )
- {
- if ( xml.readNextStartElement() )
- {
- // handle color or texture element:
- if (xml.name() == QLatin1String("color"))
- {
- material->setAmbientColor( processColorElement( xml ));
-#ifdef DEBUG_MATERIALS
- qDebug() << "set ambient color to " << material->ambientColor();
-#endif
- }
- else if ( xml.name() == QLatin1String("texture"))
- {
- effect->d->ambientTexture = processTextureElement( xml, resultState );
-#ifdef DEBUG_MATERIALS
- qDebug() << "set ambient texture to " << effect->d->ambientTexture;
-#endif
- } else if ( xml.name() == QLatin1String("param"))
- {
- qWarning() << "params not supported in lighting elements ( line" << xml.lineNumber() << ")";
- }
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("diffuse") )
- {
- if ( xml.readNextStartElement() )
- {
- // handle color or texture element:
- if (xml.name() == QLatin1String("color"))
- {
- material->setDiffuseColor( processColorElement( xml ));
-#ifdef DEBUG_MATERIALS
- qDebug() << "set diffuse color to " << material->diffuseColor();
-#endif
- }
- else if ( xml.name() == QLatin1String("texture"))
- {
- effect->d->diffuseTexture = processTextureElement( xml, resultState );
-#ifdef DEBUG_MATERIALS
- qDebug() << "set diffuse texture to " << effect->d->diffuseTexture;
-#endif
- } else if ( xml.name() == QLatin1String("param"))
- {
- qWarning() << "params not supported in lighting elements ( line" << xml.lineNumber() << ")";
- }
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("specular") )
- {
- if ( xml.readNextStartElement() )
- {
- // handle color or texture element:
- if (xml.name() == QLatin1String("color"))
- {
- material->setSpecularColor( processColorElement( xml ));
-#ifdef DEBUG_MATERIALS
- qDebug() << "set specular color to " << material->specularColor();
-#endif
- }
- else if ( xml.name() == QLatin1String("texture"))
- {
- effect->d->specularTexture = processTextureElement( xml, resultState );
-#ifdef DEBUG_MATERIALS
- qDebug() << "set specular texture to " << effect->d->specularTexture;
-#endif
- } else if ( xml.name() == QLatin1String("param"))
- {
- qWarning() << "params not supported in lighting elements ( line" << xml.lineNumber() << ")";
- }
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("shininess") )
- {
- if ( xml.readNextStartElement() )
- {
- float shininess = processParamOrFloatElement( xml );
- if ( 0.0 < shininess && shininess < 1.0 )
- {
- qWarning() << "Warning: Blinn-Torrance-Sparrow specular lighting not suported ( line" << xml.lineNumber()
- << "), converting to Blinn-Phong specular model";
- material->setShininess( int( shininess * 128.0 ));
- }
- else
- material->setShininess( int( shininess ) );
-#ifdef DEBUG_MATERIALS
- qDebug() << "set shininess to " << material->shininess();
-#endif
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("reflective") )
- {
- qWarning() << "Warning reflective not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("reflectivity") )
- {
- qWarning() << "Warning: reflectivity not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("transparent") )
- {
- if ( xml.readNextStartElement() )
- {
- if (xml.name() == QLatin1String("texture"))
- {
- QGLTexture2D* transparentTexture = processTextureElement( xml , resultState );
- Q_UNUSED(transparentTexture);
- qWarning() << "Warning: transparent not supported ( line" << xml.lineNumber() << ")";
-#ifdef DEBUG_MATERIALS
- qDebug() << "unused transparent texture" << transparentTexture;
-#endif
- }
- else if (xml.name() == QLatin1String("color"))
- {
- QColor transparent = processColorElement( xml );
- Q_UNUSED( transparent );
- qWarning() << "Warning: transparent not supported ( line" << xml.lineNumber() << ")";
-#ifdef DEBUG_MATERIALS
- qDebug() << "unused transparent color of " << transparent;
-#endif
- }
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if ( xml.name() == QLatin1String("transparency") )
- {
- if ( xml.readNextStartElement() )
- {
- float transparency = processParamOrFloatElement( xml );
- if ( transparency < 1.0 )
- {
- qWarning() << "Warning: transparency not supported";
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
- }
-
- if ( xml.name() == QLatin1String("index_of_refraction") )
- {
- if ( xml.readNextStartElement() )
- {
- float indexOfRefraction = processParamOrFloatElement( xml );
- Q_UNUSED( indexOfRefraction );
- qWarning() << "Warning: index_of_refraction not supported ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- }
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
- }
- // end of lighting scope
-
- effect->setMaterial( material );
-
- switch(effect->lighting())
- {
- case QGLColladaFxEffect::PhongLighting:
- case QGLColladaFxEffect::LambertLighting:
- qWarning() << "Warning: requested lighting not supported, using Blinn-Phong instead";
- case QGLColladaFxEffect::BlinnLighting:
- effect->addBlinnPhongLighting();
- case QGLColladaFxEffect::ConstantLighting:
- case QGLColladaFxEffect::NoLighting:
- default:
- break;
- }
- };
-
- while ( xml.name() == QLatin1String("pass") && xml.tokenType() == QXmlStreamReader::StartElement )
- {
- processPassElement( xml, resultState, effect);
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- // Make sure to exit cleanly
- findEndTag( xml, QLatin1String("technique") );
-
- return effect;
-}
-
-
-
-QGLColladaParam* QGLColladaFxEffectFactory::processNewparamElement( QXmlStreamReader& xml, ResultState* resultState)
-{
- QXmlStreamAttributes attributes = xml.attributes();
- QString sidString = attributes.value(QLatin1String("sid")).toString();
- QGLColladaParam* result = 0;
- if (xml.readNextStartElement())
- {
- if (xml.name().toString().left(5) == QLatin1String("float"))
- {
-
- QVariant floatValues = processFloatList( xml );
- resultState->paramSids[sidString] = floatValues;
-
- if ( xml.name() == QLatin1String("float")
- && ( floatValues.type() !=
- static_cast<QVariant::Type>(QMetaType::Float )))
- {
- qWarning() << "Warning: parsed type incorrectly, expected float ( line" << xml.lineNumber() << ")";
- resultState->paramSids[sidString] = floatValues.value<float>();
- }
- else if ( xml.name() == QLatin1String("float2")
- && floatValues.type() != QVariant::Vector2D )
- {
- qWarning() << "Warning: parsed type incorrectly, expected float2 ( line" << xml.lineNumber() << ")";
- }
- else if ( xml.name() == QLatin1String("float3")
- && floatValues.type() != QVariant::Vector3D )
- {
- qWarning() << "Warning: parsed type incorrectly, expected float3 ( line" << xml.lineNumber() << ")";
- }
- else if ( xml.name() == QLatin1String("float4")
- && floatValues.type() != QVariant::Vector4D)
- {
- qWarning() << "Warning: parsed type incorrectly, expected float4 ( line" << xml.lineNumber() << ")";
- }
- } else if ( xml.name() == QLatin1String("sampler2D") )
- {
- processSampler2DElement( xml , resultState, sidString );
- } else if ( xml.name() == QLatin1String("surface") )
- {
- result = processSurfaceElement( xml, resultState, sidString);
- } else {
- qWarning() << "unrecognized parameter type ( line:" << xml.lineNumber() << ")";
- findEndTag( xml, QLatin1String("newparam") );
- return 0;
- }
- }
- findEndTag(xml, QLatin1String("newparam"));
- return result;
-}
-
-
-/*!
- \internal
- the library_images can come after the library_effects, so textures referenced
- in effects might not have been defined when the effect was created. Try and
- resolve those images now. (Other properties - wrap, mipmap and filters etc
- should have been resolved when the texture was originally parsed).
- */
-bool QGLColladaFxEffectFactory::resolveTexture2DImage(QGLTexture2D *texture, ResultState *resultState, QString paramName)
-{
- if (texture == 0)
- {
- qWarning() << "Warning: Cannot resolve images for null QGLTexture2D";
- return false;
- }
- QVariant samplerParam = findParameterVariant(resultState, paramName);
- QString surfaceName = samplerParam.value<QString>();
- QImage image;
-
- if (!surfaceName.isEmpty())
- {
- QVariant surfaceParam = findParameterVariant(resultState, surfaceName);
- QString initFrom = surfaceParam.value<QString>();
- if (!initFrom.isEmpty())
- {
- image = resolveImageURI(resultState, initFrom);
- }
- }
-
- // If that's failed, try again with the passed in paramName
- if (image.isNull())
- {
- image = resolveImageURI(resultState, paramName);
- }
-
- texture->setImage(image);
- return !image.isNull();
-}
-
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGLTexture2D*);
-
-QT_BEGIN_NAMESPACE
-/*!
- \internal
- Parses and consumes a texture collada element from \a xml.
-*/
-QGLTexture2D* QGLColladaFxEffectFactory::processTextureElement( QXmlStreamReader& xml , ResultState* resultState )
-{
- QGLTexture2D* result = new QGLTexture2D();
- QXmlStreamAttributes attributes = xml.attributes();
-
- foreach (QXmlStreamAttribute attribute, attributes)
- {
- if ( attribute.name() == QLatin1String("texture") )
- {
- QString paramName = attribute.value().toString();
-
- // in Collada Fx Textures must reference a previously defined
- // sampler2D param.
- // However, this sampler may refer to images in the library_images,
- // which is parsed after the library_effects, so try and resolve
- // now, but save failures to try again later.
-
- if (!resolveTexture2DImage(result, resultState, paramName))
- {
- resultState->unresolvedTexture2Ds[result] = paramName;
- }
- } else if ( attribute.name() == QLatin1String("texcoord") )
- {
- // TODO: Create a repository for this sort of data, to be used in creating the shader progams later
- // I'm pretty sure the effect is going to need to be passed in.
- qWarning() << "texcoord not supported yet: " << attribute.name() << attribute.value() << " ( line" << xml.lineNumber() << ")";
- } else if (attribute.name() == QLatin1String("extra"))
- {
- qWarning() << "extra elements in texture elements not supported ( line" << xml.lineNumber() << ")";
- }
- }
- xml.skipCurrentElement();
-
- return result;
-}
-
-/*!
- \internal
- Try and get an image to attach to a texture. The URI could be a reference to
- a param in the collada document (which may in turn be a reference), or
- file referenced either absolutely or relative to the original dae file.
- (It could concievably be a web URL, but that is not handled here.)
- */
-QImage QGLColladaFxEffectFactory::resolveImageURI(ResultState *resultState, QString URI)
-{
- QImage result;
- QString imageFileName;
- QString workingURI = URI;
- if (workingURI.length() > 0 && workingURI.at(0) == QLatin1Char('#'))
- {
- workingURI = workingURI.right(workingURI.length() - 1);
- }
-
- QVariant potentialParameter = findParameterVariant(resultState, workingURI);
- // Might be parameter itself:
- if ( !potentialParameter.value<QImage>().isNull() )
- return potentialParameter.value<QImage>();
- // or might be another URI
- if (!potentialParameter.value<QString>().isNull())
- {
- imageFileName = potentialParameter.value<QString>();
- } else {
- imageFileName = workingURI;
- }
-
- // First try as a relative path.
- QString filePath = resultState->sourceDir.path() + QLatin1Char('/') + imageFileName;
- result.load(filePath);
- if (result.isNull())
- {
- // No relative file found, so try as an absolute path
- result.load(imageFileName);
- }
- return result;
-}
-
-/*!
- \internal
- Parses and consumes an image element from \a xml.
-*/
-void QGLColladaFxEffectFactory::processImageElement( QXmlStreamReader& xml, ResultState* resultState )
-{
- // 1.4 has a bunch of optional values in the attributes:
- QString sid = xml.attributes().value(QLatin1String("sid")).toString();
- QString id = xml.attributes().value(QLatin1String("id")).toString();
- QString name = xml.attributes().value(QLatin1String("name")).toString();
-
- QString height = xml.attributes().value(QLatin1String("height")).toString();
- QString width = xml.attributes().value(QLatin1String("width")).toString();
- QString depth = xml.attributes().value(QLatin1String("depth")).toString();
-
- Q_UNUSED(height);
- Q_UNUSED(width);
- Q_UNUSED(depth);
-
- QImage result;
-
- xml.readNextStartElement();
- if (xml.name() == QLatin1String("asset"))
- {
- qWarning() << "asset element not supported in image elements ( line" << xml.lineNumber() << ")";
- xml.skipCurrentElement();
- xml.readNextStartElement();
- }
-
- if (xml.name() == QLatin1String("init_from"))
- {
- QString imageFileName = xml.readElementText().trimmed();
- QDir sourceDir = resultState->sourceDir;
- // ignore path information for resources
- QString filePath = sourceDir.path() + QLatin1Char('/') + imageFileName;
- result.load(filePath);
- if (result.isNull())
- {
- // Catch resources or files with absolute paths
- result.load(imageFileName);
- }
- if (!sid.isEmpty())
- resultState->paramSids[sid] = result;
- if (!id.isEmpty())
- resultState->paramIds[id] = result;
- if (!name.isEmpty())
- resultState->paramNames[name] = result;
- }
-
- // exit cleanly
- findEndTag( xml, QLatin1String("image"));
-}
-
-QStringList QGLColladaFxEffectFactory::glslProfileFromEffect(QGLColladaFxEffect* effect, QString sid)
-{
- Q_UNUSED(effect)
- Indent indent;
- QStringList result;
- result += indent + QLatin1String("<profile_GLSL>");
- {
- result += generateCodeElements(effect, sid);
- result += indent + QLatin1String("<technique sid=\"") + sid + QLatin1String("\">");
- {
- Indent indent;
- result += indent + QLatin1String("<pass>");
- result += generateProgramElement(effect, sid);
- result += indent + QLatin1String("</pass>");
- }
- result += indent + QLatin1String("</technique>");
- }
- result += indent + QLatin1String("</profile_GLSL>");
-
- return result;
-}
-
-QStringList QGLColladaFxEffectFactory::generateProgramElement(QGLColladaFxEffect* effect, QString techniqueSid)
-{
- QStringList result;
- QString vertexShaderRefSid = QLatin1String("VertexShaderRefSidRefsCodeOrIncludeAtProfileOrEffectLevel");
- QString fragmentShaderRefSid = QLatin1String("FragmentShaderRefSidRefsCodeOrIncludeAtProfileOrEffectLevel");
- Indent indent;
- result += indent + QLatin1String("<program>");
- result += generateShaderElement(effect, techniqueSid + QLatin1String("VertexShader"), techniqueSid + QLatin1String("FragmentShader"));
- // 0 or more
- result += generateBindAttributeElement( effect );
- // 0 or more
- result += generateBindUniformElements( effect );
- result += indent + QLatin1String("</program>");
- return result;
-}
-
-QStringList QGLColladaFxEffectFactory::generateShaderElement( QGLColladaFxEffect* effect, QString vertexShaderRefSid, QString fragmentShaderRefSid )
-{
- Q_UNUSED(effect);
- QStringList result;
- Indent indent;
- result += indent + QLatin1String("<shader stage=\"VERTEX\">");
- {
- Indent indent;
- result += indent + QLatin1String("<sources>");
- {
- // 0 or more <import> elements
- Indent indent;
- result += indent + QLatin1String("<import ref=\"") + vertexShaderRefSid + QLatin1String("\"/>");
- }
- result += indent + QLatin1String("</sources>");
- // 0 or <extra> elements;
- }
- result += indent + QLatin1String("</shader>");
-
- result += indent + QLatin1String("<shader stage=\"FRAGMENT\">");
- {
- Indent indent;
- result += indent + QLatin1String("<sources>");
- {
- Indent indent;
- result += indent + QLatin1String("<import ref=\"") + fragmentShaderRefSid + QLatin1String("\"/>");
- }
- result += indent + QLatin1String("</sources>");
- // <extra> element(s) here if necessary;
- }
- result += indent + QLatin1String("</shader>");
- return result;
-}
-
-QStringList QGLColladaFxEffectFactory::generateBindAttributeElement( QGLColladaFxEffect* effect )
-{
- // Currently no need for bind_attribute elements.
- Q_UNUSED(effect);
- QStringList result;
- // Indent indent;
- // result += indent + "<bind_attribute>";
- // result += indent + "</bind_attribute>";
- return result;
-}
-
-QStringList generateBindUniformParamElement( QString symbol, QString ref)
-{
- QStringList result;
- // 0 or more <bind_uniform> elements
- Indent indent;
- result += indent + QLatin1String("<bind_uniform symbol=\"") + symbol + QLatin1String("\">");
- {
- Indent indent;
- result += indent + QLatin1String("<param ref=\"") + ref + QLatin1String("\">");
- }
- result += indent + QLatin1String("</bind_uniform>");
- return result;
-}
-
-QStringList generateBindUniformParamElement( QString symbol, const QVector3D& value)
-{
- QStringList result;
- // 0 or more <bind_uniform> elements
- Indent indent;
- result += indent + QLatin1String("<bind_uniform symbol=\"") + symbol + QLatin1String("\">");
- {
- Indent indent;
- result += indent + QString(QLatin1String("<float3> %1 %2 %3 </float3>")).arg(value.x()).arg(value.y()).arg(value.z());
- }
- result += indent + QLatin1String("</bind_uniform>");
- return result;
-}
-
-QStringList generateBindUniformParamElement( QString symbol, const QColor& value)
-{
- QStringList result;
- // 0 or more <bind_uniform> elements
- Indent indent;
- result += indent + QLatin1String("<bind_uniform symbol=\"") + symbol + QLatin1String("\">");
- {
- Indent indent;
- result += indent + QString(QLatin1String("<float3> %1 %2 %3 </float3>")).arg(value.redF()).arg(value.greenF()).arg(value.blueF());
- }
- result += indent + QLatin1String("</bind_uniform>");
- return result;
-}
-
-
-QStringList QGLColladaFxEffectFactory::generateBindUniformElements( QGLColladaFxEffect* effect )
-{
- QStringList result;
- if (effect == 0)
- return result;
- // // 0 or more <bind_uniform> elements
- // Example uniforms
- // result += generateBindUniformParamElement( "exampleRefSymbol", QString("exampleRef"));
- // result += generateBindUniformParamElement( "exampleFloat3Symbol", QVector3D(0.1, 0.2, 0.3) );
-
- if (effect->material() != 0)
- {
- QGLMaterial* material = effect->material();
-
- // Actual uniforms:
- result += generateBindUniformParamElement( QLatin1String("ambientColor"), material->ambientColor());
- result += generateBindUniformParamElement( QLatin1String("diffuseColor"), material->diffuseColor());
- result += generateBindUniformParamElement( QLatin1String("emittedLight"), material->emittedLight());
- result += generateBindUniformParamElement( QLatin1String("objectName"), material->objectName());
- result += generateBindUniformParamElement( QLatin1String("shininess"), material->shininess());
- result += generateBindUniformParamElement( QLatin1String("specularColor"), material->specularColor());
-
- effect->supportsPicking();
-
- // TODO: Find and store effect uniforms
- // effect->bindProgramUniforms();
- }
- return result;
-}
-
-QStringList QGLColladaFxEffectFactory::generateCodeElements( QGLColladaFxEffect* effect, QString baseSid )
-{
- QStringList result;
- // 0 or more <bind_uniform> elements
- Indent indent;
-
- // put all this on one line to avoid adding carriage returns to the
- // shader programs
- result += indent + QLatin1String("<code sid=\"") + baseSid + QLatin1String("VertexShader\">")
- + effect->vertexShader() + QLatin1String("</code>");
-
- result += indent + QLatin1String("<code sid=\"") + baseSid + QLatin1String("FragmentShader\">")
- + effect->fragmentShader() + QLatin1String("</code>");
-
- return result;
-}
-
-void QGLColladaFxEffectFactory::processProgramElement( QXmlStreamReader& xml, ResultState* resultState, QGLColladaFxEffect* effect )
-{
- // A profile_GLSL shader element is
- // 0 or more <shader>
- // 0 or more <bind_attribute>
- // 0 or more <bind_uniform>
-
- xml.readNextStartElement();
-
- while ( xml.name() == QLatin1String("shader") )
- {
- // in profile_GLSL a shader is
- // exactly 1 <source>
- // 0 or more <extra>
-
- QString stage = xml.attributes().value(QLatin1String("stage")).toString();
- xml.readNextStartElement();
- if ( xml.name() == QLatin1String("sources") )
- {
- // a <sources> element is
- // 1 or more <inline> elements
- // 0 or more <import> elements
- // Note: child elements can appear in any order
-
- xml.readNextStartElement();
- while ( (xml.name() == QLatin1String("inline") || xml.name() == QLatin1String("import")) && xml.tokenType() == QXmlStreamReader::StartElement)
- {
- if ( xml.name() == QLatin1String("import"))
- {
- QString ref = xml.attributes().value(QLatin1String("ref")).toString();
-
- QXmlStreamAttribute attr;
- if (xml.attributes().count())
- {
- attr = xml.attributes().first();
- }
-
- QVariant param = findParameterVariant(resultState, ref);
- if (param.isNull() || param.type() != QVariant::String)
- {
- qWarning() << "null or unexpected parameter found in import element ( line"
- << xml.lineNumber()<<")";
- }
- else
- {
- if (stage == QLatin1String("VERTEX"))
- {
- effect->setVertexShader( param.value<QString>().toLatin1() );
- }
- else if (stage == QLatin1String("FRAGMENT"))
- {
- effect->setFragmentShader( param.value<QString>().toLatin1() );
- } else
- {
- qWarning() << "unrecognized shader stage: "
- << stage << " ( line" << xml.lineNumber()<<")";
- }
- }
-
- } else if ( xml.name() == QLatin1String("inline"))
- {
-
- }
- xml.readNextStartElement();
- }
- } else {
- qWarning() << "collada parsing error. expected <sources> element ( line"
- << xml.lineNumber()<<")";
- }
-
- if (xml.name() == QLatin1String("extra"))
- qWarning() << "Warning: extra element not supported in profile_GLSL <shader> element ( line" << xml.lineNumber()<<")";
-
- findEndTag ( xml, QLatin1String("shader"));
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("bind_attribute") )
- {
- qWarning() << "Warning: bind_attribute element not supported ( line" << xml.lineNumber()<<")";
- findEndTag ( xml, QLatin1String("bind_attribute"));
- xml.readNextStartElement();
- }
-
- while ( xml.name() == QLatin1String("bind_uniform") )
- {
- qWarning() << "Warning: bind_uniform element not supported ( line" << xml.lineNumber()<<")";
- findEndTag ( xml, QLatin1String("bind_uniform"));
- xml.readNextStartElement();
- }
-
- findEndTag(xml, QLatin1String("program"));
- return;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglcolladafxeffectfactory.h b/src/threed/effects/qglcolladafxeffectfactory.h
deleted file mode 100644
index 1ed5bb9e..00000000
--- a/src/threed/effects/qglcolladafxeffectfactory.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCOLLADAFXEFFECTFACTORY_H
-#define QGLCOLLADAFXEFFECTFACTORY_H
-
-#include <QVector>
-#include <QXmlStreamReader>
-#include <QDir>
-#include "qgl.h"
-#include "qgltexture2d.h"
-
-#include "qglcolladafxeffect.h"
-
-Q_DECLARE_METATYPE(QArray<float>)
-
-QT_BEGIN_NAMESPACE
-
-class QGLColladaFxEffect;
-class QGLColladaImageParam;
-class QGLColladaSurfaceParam;
-class QGLColladaSampler2DParam;
-
-typedef struct _ResultState
-{
- QMap<QString, QVariant> paramSids;
- QMap<QString, QVariant> paramIds;
- QMap<QString, QVariant> paramNames;
- QDir sourceDir;
- QMap<QGLTexture2D*, QString> unresolvedTexture2Ds;
-} ResultState;
-
-
-
-
-class Q_QT3D_EXPORT QGLColladaFxEffectFactory
-{
-public:
- // Collada parsing functions
- static QList<QGLColladaFxEffect*> loadEffectsFromFile(const QString& fileName );
-
-protected:
- static QList<QGLColladaFxEffect*> loadEffectsFromXml( QXmlStreamReader& xml, QDir homeDirectory = QDir());
- static void processLibraryImagesElement( QXmlStreamReader& xml, ResultState* stateStack );
- static QList<QGLColladaFxEffect*> processLibraryEffectsElement( QXmlStreamReader& xml, ResultState* stateStack );
- static QList<QGLColladaFxEffect*> processEffectElement( QXmlStreamReader& xml, ResultState* stateStack );
- static QList<QGLColladaFxEffect*> processProfileElement( QXmlStreamReader& xml, ResultState* stateStack );
-
- static QGLColladaParam* processPassElement( QXmlStreamReader& xml, ResultState* stateStack, QGLColladaFxEffect* effect );
- static QGLColladaFxEffect* processTechniqueElement( QXmlStreamReader& xml, ResultState* stateStack, QString &profileName );
- static QGLColladaParam* processNewparamElement( QXmlStreamReader& xml, ResultState* stateStack );
- static void processImageElement( QXmlStreamReader& xml, ResultState* stateStack );
- static QGLColladaSurfaceParam* processSurfaceElement( QXmlStreamReader& xml, ResultState* stateStack, QString passedInSid = "");
- static void processSampler2DElement( QXmlStreamReader& xml, ResultState* stateStack, QString passedInSid );
- static QGLTexture2D* processTextureElement( QXmlStreamReader& xml , ResultState* stateStack );
- static QVariant processFloatList( QXmlStreamReader& xml );
- static QColor processColorElement( QXmlStreamReader& xml );
- static float processParamOrFloatElement( QXmlStreamReader& xml );
- static QVariant processColorOrTextureElement( QXmlStreamReader& xml );
- QGLColladaFxEffectFactory();
- static void processProgramElement( QXmlStreamReader& xml, ResultState* stateStack, QGLColladaFxEffect* effect );
-
- // Collada generation functions
-public:
- static QString exportEffect(QGLColladaFxEffect *effect, QString effectId, QString techniqueSid);
-
-protected:
- static QStringList glslProfileFromEffect(QGLColladaFxEffect* effect, QString techniqueSid);
- static QStringList generateProgramElement(QGLColladaFxEffect* effect, QString techniqueSid);
- static QStringList generateShaderElement( QGLColladaFxEffect* effect, QString vertexShaderRefSid, QString fragmentShaderRefSid );
- static QStringList generateBindUniformElement( QGLColladaFxEffect* effect );
- static QStringList generateBindAttributeElement( QGLColladaFxEffect* effect );
- static QStringList generateBindUniformElements( QGLColladaFxEffect* effect );
- static QStringList generateCodeElements( QGLColladaFxEffect* effect, QString baseSid );
-
- static QImage resolveImageURI(ResultState *resultState, QString imageFileName);
- static bool resolveTexture2DImage(QGLTexture2D *result, ResultState *resultState, QString paramName);
-};
-
-
-
-class QGLColladaParam
-{
- friend class QGLColladaFxEffectFactory;
-public:
- enum {
- UnknownType = 0,
- Sampler2DType,
- Texture2DType,
- SurfaceType,
- ImageType,
- UserDefinedType = 100
- };
-
- virtual ~QGLColladaParam();
-
- int type();
- QVector<float> value();
- QString sid();
- QString id();
-
- static QString typeString(int);
-
-protected:
- QGLColladaParam(QString sid, int type);
- QString mSid;
- QString mId;
- int mType;
- QVector<float> mValue;
-};
-
-
-
-class QGLColladaTextureParam : public QGLColladaParam
-{
- friend class QGLColladaFxEffectFactory;
-public:
- QGLColladaTextureParam(QString sid, QGLTexture2D* texture);
- QGLTexture2D* texture();
- QString samplerSid();
-protected:
- QGLTexture2D* mTexture;
- QString sampler2DSid;
- QString texCoordSid;
-};
-
-
-
-class QGLColladaSurfaceParam : public QGLColladaParam
-{
- friend class QGLColladaFxEffectFactory;
-public:
- QGLColladaSurfaceParam(QString sid);
-protected:
- QString mInitFrom;
- QString mFormat;
- QString mFormatHint;
- QString mSize;
- QVector<int> mSizeVector;
- QPointF mViewportRatio;
- int mMipLevels;
- bool mMipMapGenerate;
- QString mExtra;
- QString mGenerator;
-};
-
-
-
-class QGLColladaSampler2DParam : public QGLColladaParam
-{
- friend class QGLColladaFxEffectFactory;
-public:
- QGLColladaSampler2DParam(QString sid, QGLTexture2D* sampler);
- QGLColladaSampler2DParam(QString sid, QString sourceSid);
- QGLTexture2D sampler();
- QString sourceSid();
-protected:
- QGLTexture2D* mTexture;
- QString mSourceSid;
-};
-
-
-
-// "image" isn't really a param, but it shares enough that it seems sensible
-// to re-use the QGLColladaParam base.
-class QGLColladaImageParam : public QGLColladaParam
-{
- friend class QGLColladaFxEffectFactory;
-public:
- QGLColladaImageParam(QString sid, QImage image);
- QImage image();
- QString name();
-protected:
- QImage mImage;
- QString mName;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLCOLLADAFXEFFECTFACTORY_H
diff --git a/src/threed/effects/qglcolladafxeffectloader.cpp b/src/threed/effects/qglcolladafxeffectloader.cpp
deleted file mode 100644
index cb181257..00000000
--- a/src/threed/effects/qglcolladafxeffectloader.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcolladafxeffectloader.h"
-
-#include <QList>
-#include "qglcolladafxeffectfactory.h"
-#include "qglcolladafxeffect.h"
-
-#include <QStringList>
-
-//Q_DECLARE_METATYPE(QGLColladaFxEffect)
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLColladaFxEffectLoader
- \brief The QGLColladaFxEffectLoader class is a convenient way to load
- effects from collada files for use with Qt3D.
- \since 4.8
- \ingroup qt3d
-
- QGLColladaFxEffectLoader provides a simple class to create and store
- QGLColladaEffect objects from Collada Fx files. It currently supports
- a simple subset of the Collada 1.5 Fx specification.
-
- The QGLColladaEffect effects are destroyed automatically when the loader
- is destroyed. If finer control over effect lifetime is required, use
- QGLColladaFxEffectFactory::loadEffectsFromFile() directly.
-*/
-
-class QGLColladaFxEffectLoaderPrivate
-{
-public:
- QList<QGLColladaFxEffect*> effects;
- ~QGLColladaFxEffectLoaderPrivate()
- {
- deleteAndClearEffects();
- }
-
- void deleteAndClearEffects()
- {
- while (effects.count())
- {
- delete effects.back();
- effects.pop_back();
- }
- }
-
-};
-
-
-/*!
- Constructs an empty QGLColladaFxEffectLoader object.
-*/
-QGLColladaFxEffectLoader::QGLColladaFxEffectLoader() :
- d_ptr(new QGLColladaFxEffectLoaderPrivate())
-{
-}
-
-/*!
- Destroys the QGLColladaFxEffectLoader and any generated QGLColladaFxEffect
- objects.
-*/
-QGLColladaFxEffectLoader::~QGLColladaFxEffectLoader()
-{
-}
-
-/*!
- Reads the collada file indicated by \a filename and generates
- QGLColladaFxEffect objects from it.
-
- The QGLColladaFxEffectFactory owns all the effects it generates, and destroys
- them when it is destroyed, or when a new file is loaded.
-
- If effects are needed from multiple files, use one QGLColladaFxEffectLoader
- per file.
-
- Returns true if at least one effect was generated.
-
- \sa effectNames(), effect(), operator[](), QGLColladaFxEffectFactory::loadEffectsFromFile()
- */
-bool QGLColladaFxEffectLoader::load(QString filename)
-{
- Q_D(QGLColladaFxEffectLoader);
- d->deleteAndClearEffects();
- d->effects = QGLColladaFxEffectFactory::loadEffectsFromFile(filename);
- return d->effects.count() > 0;
-}
-
-/*!
- Returns a list of the sid attributes of effects that have been generated
- \sa effect()
- */
-QStringList QGLColladaFxEffectLoader::effectNames()
-{
- Q_D(QGLColladaFxEffectLoader);
- QStringList result;
- QGLColladaFxEffect *effect;
- foreach (effect, d->effects)
- {
- result.append(effect->sid());
- }
- return result;
-}
-
-/*!
- Returns a pointer to the effect with an sid matching \a effectName, or
- 0 if no such effect exists.
-
- \sa load()
- */
-QGLColladaFxEffect* QGLColladaFxEffectLoader::effect(QString effectName)
-{
- Q_D(QGLColladaFxEffectLoader);
- QGLColladaFxEffect* effect;
-
- foreach (effect, d->effects)
- {
- if (effect && effect->sid() == effectName)
- {
- return effect;
- }
- }
- return 0;
-}
-
-/*!
- Returns the number of effects the loader has generated and stored.
- */
-int QGLColladaFxEffectLoader::count()
-{
- Q_D(QGLColladaFxEffectLoader);
- return d->effects.count();
-}
-
-/*!
- Returns a pointer to the effect in position \a i. QGLColladaFxEffectLoader
- makes no guarantee about the ordering of effects relative to their position
- in a collada document, but does not reorder effects once they have been read.
-
- \sa load()
- */
-QGLColladaFxEffect *QGLColladaFxEffectLoader::operator[](int i)
-{
- Q_D(QGLColladaFxEffectLoader);
- Q_ASSERT(i < d->effects.count());
-
- return d->effects.at(i);
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglcolladafxeffectloader.h b/src/threed/effects/qglcolladafxeffectloader.h
deleted file mode 100644
index 84dbcf84..00000000
--- a/src/threed/effects/qglcolladafxeffectloader.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCOLLADAFXEFFECTLOADER_H
-#define QGLCOLLADAFXEFFECTLOADER_H
-
-#include <qglobal.h>
-#include <QString>
-#include <QStringList>
-#include <QtCore/qscopedpointer.h>
-#include "qt3dglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLColladaFxEffect;
-class QGLColladaFxEffectLoaderPrivate;
-
-class Q_QT3D_EXPORT QGLColladaFxEffectLoader
-{
-public:
- QGLColladaFxEffectLoader();
- ~QGLColladaFxEffectLoader();
- bool load(QString filename);
- QStringList effectNames();
- QGLColladaFxEffect *effect(QString effectName);
- int count();
- QGLColladaFxEffect* operator[](int);
-private:
- Q_DECLARE_PRIVATE(QGLColladaFxEffectLoader);
- QScopedPointer<QGLColladaFxEffectLoaderPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLCOLLADAFXEFFECTLOADER_H
diff --git a/src/threed/effects/qglflatcoloreffect.cpp b/src/threed/effects/qglflatcoloreffect.cpp
deleted file mode 100644
index e082b38e..00000000
--- a/src/threed/effects/qglflatcoloreffect.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglflatcoloreffect_p.h"
-#include "qglabstracteffect_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLFlatColorEffect
- \since 4.8
- \brief The QGLFlatColorEffect class provides a standard effect that draws fragments with a flat unlit color.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-/*!
- \class QGLPerVertexColorEffect
- \since 4.8
- \brief The QGLPerVertexColorEffect class provides a standard effect that draws fragments with a per-vertex unlit color.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-class QGLFlatColorEffectPrivate
-{
-public:
- QGLFlatColorEffectPrivate()
- : program(0)
- , matrixUniform(-1)
- , colorUniform(-1)
- , isFixedFunction(false)
- {
- }
-
- QGLShaderProgram *program;
- int matrixUniform;
- int colorUniform;
- bool isFixedFunction;
-};
-
-/*!
- Constructs a new flat color effect.
-*/
-QGLFlatColorEffect::QGLFlatColorEffect()
- : d_ptr(new QGLFlatColorEffectPrivate)
-{
-}
-
-/*!
- Destroys this flat color effect.
-*/
-QGLFlatColorEffect::~QGLFlatColorEffect()
-{
-}
-
-/*!
- \reimp
-*/
-bool QGLFlatColorEffect::supportsPicking() const
-{
- return true;
-}
-
-/*!
- \reimp
-*/
-void QGLFlatColorEffect::setActive(QGLPainter *painter, bool flag)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- Q_UNUSED(painter);
- if (flag)
- glEnableClientState(GL_VERTEX_ARRAY);
- else
- glDisableClientState(GL_VERTEX_ARRAY);
-#else
- Q_UNUSED(painter);
- Q_D(QGLFlatColorEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (painter->isFixedFunction()) {
- d->isFixedFunction = true;
- if (flag)
- glEnableClientState(GL_VERTEX_ARRAY);
- else
- glDisableClientState(GL_VERTEX_ARRAY);
- return;
- }
-#endif
- static char const flatColorVertexShader[] =
- "attribute highp vec4 vertex;\n"
- "uniform highp mat4 matrix;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = matrix * vertex;\n"
- "}\n";
-
- static char const flatColorFragmentShader[] =
- "uniform mediump vec4 color;\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = color;\n"
- "}\n";
-
- QGLShaderProgram *program =
- painter->cachedProgram(QLatin1String("qt.color.flat"));
- d->program = program;
- if (!program) {
- if (!flag)
- return;
- program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, flatColorVertexShader);
- program->addShaderFromSourceCode(QGLShader::Fragment, flatColorFragmentShader);
- program->bindAttributeLocation("vertex", QGL::Position);
- if (!program->link()) {
- qWarning("QGLFlatColorEffect::setActive(): could not link shader program");
- delete program;
- return;
- }
- painter->setCachedProgram(QLatin1String("qt.color.flat"), program);
- d->program = program;
- d->colorUniform = program->uniformLocation("color");
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->enableAttributeArray(QGL::Position);
- } else if (flag) {
- d->colorUniform = program->uniformLocation("color");
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->enableAttributeArray(QGL::Position);
- } else {
- program->disableAttributeArray(QGL::Position);
- program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLFlatColorEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateColor |
- QGLPainter::UpdateMatrices));
-#else
- Q_D(QGLFlatColorEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->isFixedFunction) {
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateColor |
- QGLPainter::UpdateMatrices));
- return;
- }
-#endif
- if ((updates & QGLPainter::UpdateColor) != 0) {
- if (painter->isPicking())
- d->program->setUniformValue(d->colorUniform, painter->pickColor());
- else
- d->program->setUniformValue(d->colorUniform, painter->color());
- }
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- QMatrix4x4 proj = painter->projectionMatrix();
- QMatrix4x4 mv = painter->modelViewMatrix();
- d->program->setUniformValue(d->matrixUniform, proj * mv);
- }
-#endif
-}
-
-class QGLPerVertexColorEffectPrivate
-{
-public:
- QGLPerVertexColorEffectPrivate()
- : program(0)
- , matrixUniform(-1)
- , isFixedFunction(false)
- {
- }
-
- QGLShaderProgram *program;
- int matrixUniform;
- bool isFixedFunction;
-};
-
-/*!
- Constructs a new per-vertex color effect.
-*/
-QGLPerVertexColorEffect::QGLPerVertexColorEffect()
- : d_ptr(new QGLPerVertexColorEffectPrivate)
-{
-}
-
-/*!
- Destroys this per-vertex color effect.
-*/
-QGLPerVertexColorEffect::~QGLPerVertexColorEffect()
-{
-}
-
-/*!
- \reimp
-*/
-void QGLPerVertexColorEffect::setActive(QGLPainter *painter, bool flag)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- Q_UNUSED(painter);
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- }
-#else
- Q_UNUSED(painter);
- Q_D(QGLPerVertexColorEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (painter->isFixedFunction()) {
- d->isFixedFunction = true;
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- }
- return;
- }
-#endif
- static char const pvColorVertexShader[] =
- "attribute highp vec4 vertex;\n"
- "attribute mediump vec4 color;\n"
- "uniform highp mat4 matrix;\n"
- "varying mediump vec4 qColor;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = matrix * vertex;\n"
- " qColor = color;\n"
- "}\n";
-
- static char const pvColorFragmentShader[] =
- "varying mediump vec4 qColor;\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = qColor;\n"
- "}\n";
-
- QGLShaderProgram *program =
- painter->cachedProgram(QLatin1String("qt.color.pervertex"));
- d->program = program;
- if (!program) {
- if (!flag)
- return;
- program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, pvColorVertexShader);
- program->addShaderFromSourceCode(QGLShader::Fragment, pvColorFragmentShader);
- program->bindAttributeLocation("vertex", QGL::Position);
- program->bindAttributeLocation("color", QGL::Color);
- if (!program->link()) {
- qWarning("QGLPerVertexColorEffect::setActive(): could not link shader program");
- delete program;
- program = 0;
- return;
- }
- painter->setCachedProgram(QLatin1String("qt.color.pervertex"), program);
- d->program = program;
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::Color);
- } else if (flag) {
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::Color);
- } else {
- program->disableAttributeArray(QGL::Position);
- program->disableAttributeArray(QGL::Color);
- program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLPerVertexColorEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- painter->updateFixedFunction(updates & QGLPainter::UpdateMatrices);
-#else
- Q_UNUSED(painter);
- Q_D(QGLPerVertexColorEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->isFixedFunction) {
- painter->updateFixedFunction(updates & QGLPainter::UpdateMatrices);
- return;
- }
-#endif
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- d->program->setUniformValue
- (d->matrixUniform, painter->combinedMatrix());
- }
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglflatcoloreffect_p.h b/src/threed/effects/qglflatcoloreffect_p.h
deleted file mode 100644
index 8f713712..00000000
--- a/src/threed/effects/qglflatcoloreffect_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLFLATCOLOREFFECT_P_H
-#define QGLFLATCOLOREFFECT_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.
-//
-
-#include "qglabstracteffect.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLFlatColorEffectPrivate;
-class QGLPerVertexColorEffectPrivate;
-
-class QGLFlatColorEffect : public QGLAbstractEffect
-{
-public:
- QGLFlatColorEffect();
- virtual ~QGLFlatColorEffect();
-
- bool supportsPicking() const;
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
-private:
- QScopedPointer<QGLFlatColorEffectPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLFlatColorEffect)
- Q_DISABLE_COPY(QGLFlatColorEffect)
-};
-
-class QGLPerVertexColorEffect : public QGLAbstractEffect
-{
-public:
- QGLPerVertexColorEffect();
- virtual ~QGLPerVertexColorEffect();
-
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
-private:
- QScopedPointer<QGLPerVertexColorEffectPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLPerVertexColorEffect)
- Q_DISABLE_COPY(QGLPerVertexColorEffect)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/effects/qglflattextureeffect.cpp b/src/threed/effects/qglflattextureeffect.cpp
deleted file mode 100644
index 3e93ff48..00000000
--- a/src/threed/effects/qglflattextureeffect.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglflattextureeffect_p.h"
-#include "qglabstracteffect_p.h"
-#include "qglext_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLFlatTextureEffect
- \since 4.8
- \brief The QGLFlatTextureEffect class provides a standard effect that draws fragments with a flat unlit texture.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-/*!
- \class QGLFlatDecalTextureEffect
- \since 4.8
- \brief The QGLFlatDecalTextureEffect class provides a standard effect that decals fragments with a flat unlit texture.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-class QGLFlatTextureEffectPrivate
-{
-public:
- QGLFlatTextureEffectPrivate()
- : program(0)
- , matrixUniform(-1)
- , isFixedFunction(false)
- {
- }
-
- QGLShaderProgram *program;
- int matrixUniform;
- bool isFixedFunction;
-};
-
-/*!
- Constructs a new flat texture effect.
-*/
-QGLFlatTextureEffect::QGLFlatTextureEffect()
- : d_ptr(new QGLFlatTextureEffectPrivate)
-{
-}
-
-/*!
- Destroys this flat texture effect.
-*/
-QGLFlatTextureEffect::~QGLFlatTextureEffect()
-{
-}
-
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
-
-static char const flatTexVertexShader[] =
- "attribute highp vec4 vertex;\n"
- "attribute highp vec4 texcoord;\n"
- "uniform highp mat4 matrix;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = matrix * vertex;\n"
- " qt_TexCoord0 = texcoord;\n"
- "}\n";
-
-static char const flatTexFragmentShader[] =
- "uniform sampler2D tex;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = texture2D(tex, qt_TexCoord0.st);\n"
- "}\n";
-
-static char const flatDecalFragmentShader[] =
- "uniform sampler2D tex;\n"
- "uniform mediump vec4 color;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "void main(void)\n"
- "{\n"
- " mediump vec4 col = texture2D(tex, qt_TexCoord0.st);\n"
- " gl_FragColor = vec4(clamp(color.rgb * (1.0 - col.a) + col.rgb, 0.0, 1.0), color.a);\n"
- "}\n";
-
-#endif
-
-/*!
- \reimp
-*/
-void QGLFlatTextureEffect::setActive(QGLPainter *painter, bool flag)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- Q_UNUSED(painter);
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glEnable(GL_TEXTURE_2D);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
-#else
- Q_UNUSED(painter);
- Q_D(QGLFlatTextureEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (painter->isFixedFunction()) {
- d->isFixedFunction = true;
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glEnable(GL_TEXTURE_2D);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
- return;
- }
-#endif
- QGLShaderProgram *program =
- painter->cachedProgram(QLatin1String("qt.texture.flat.replace"));
- d->program = program;
- if (!program) {
- if (!flag)
- return;
- program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, flatTexVertexShader);
- program->addShaderFromSourceCode(QGLShader::Fragment, flatTexFragmentShader);
- program->bindAttributeLocation("vertex", QGL::Position);
- program->bindAttributeLocation("texcoord", QGL::TextureCoord0);
- if (!program->link()) {
- qWarning("QGLFlatTextureEffect::setActive(): could not link shader program");
- delete program;
- program = 0;
- return;
- }
- painter->setCachedProgram
- (QLatin1String("qt.texture.flat.replace"), program);
- d->program = program;
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::TextureCoord0);
- } else if (flag) {
- d->matrixUniform = program->uniformLocation("matrix");
- program->bind();
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::TextureCoord0);
- } else {
- program->disableAttributeArray(QGL::Position);
- program->disableAttributeArray(QGL::TextureCoord0);
- program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLFlatTextureEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- painter->updateFixedFunction(updates & QGLPainter::UpdateMatrices);
-#else
- Q_D(QGLFlatTextureEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->isFixedFunction) {
- painter->updateFixedFunction(updates & QGLPainter::UpdateMatrices);
- return;
- }
-#endif
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- d->program->setUniformValue
- (d->matrixUniform, painter->combinedMatrix());
- }
-#endif
-}
-
-class QGLFlatDecalTextureEffectPrivate
-{
-public:
- QGLFlatDecalTextureEffectPrivate()
- : program(0)
- , matrixUniform(-1)
- , colorUniform(-1)
- , isFixedFunction(false)
- {
- }
-
- QGLShaderProgram *program;
- int matrixUniform;
- int colorUniform;
- bool isFixedFunction;
-};
-
-/*!
- Constructs a new flat decal texture effect.
-*/
-QGLFlatDecalTextureEffect::QGLFlatDecalTextureEffect()
- : d_ptr(new QGLFlatDecalTextureEffectPrivate)
-{
-}
-
-/*!
- Destroys this flat decal texture effect.
-*/
-QGLFlatDecalTextureEffect::~QGLFlatDecalTextureEffect()
-{
-}
-
-/*!
- \reimp
-*/
-void QGLFlatDecalTextureEffect::setActive(QGLPainter *painter, bool flag)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- Q_UNUSED(painter);
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glEnable(GL_TEXTURE_2D);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
-#else
- Q_UNUSED(painter);
- Q_D(QGLFlatDecalTextureEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (painter->isFixedFunction()) {
- d->isFixedFunction = true;
- if (flag) {
- glEnableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glEnable(GL_TEXTURE_2D);
- } else {
- glDisableClientState(GL_VERTEX_ARRAY);
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
- }
-#endif
- QGLShaderProgram *program =
- painter->cachedProgram(QLatin1String("qt.texture.flat.decal"));
- d->program = program;
- if (!program) {
- if (!flag)
- return;
- program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, flatTexVertexShader);
- program->addShaderFromSourceCode(QGLShader::Fragment, flatDecalFragmentShader);
- program->bindAttributeLocation("vertex", QGL::Position);
- program->bindAttributeLocation("texcoord", QGL::TextureCoord0);
- if (!program->link()) {
- qWarning("QGLFlatDecalTextureEffect::setActive(): could not link shader program");
- delete program;
- program = 0;
- return;
- }
- painter->setCachedProgram
- (QLatin1String("qt.texture.flat.decal"), program);
- d->program = program;
- d->matrixUniform = program->uniformLocation("matrix");
- d->colorUniform = program->uniformLocation("color");
- program->bind();
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::TextureCoord0);
- } else if (flag) {
- d->matrixUniform = program->uniformLocation("matrix");
- d->colorUniform = program->uniformLocation("color");
- program->bind();
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::TextureCoord0);
- } else {
- program->disableAttributeArray(QGL::Position);
- program->disableAttributeArray(QGL::TextureCoord0);
- program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLFlatDecalTextureEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateColor |
- QGLPainter::UpdateMatrices));
-#else
- Q_D(QGLFlatDecalTextureEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->isFixedFunction) {
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateColor |
- QGLPainter::UpdateMatrices));
- return;
- }
-#endif
- if ((updates & QGLPainter::UpdateColor) != 0)
- d->program->setUniformValue(d->colorUniform, painter->color());
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- d->program->setUniformValue
- (d->matrixUniform, painter->combinedMatrix());
- }
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglflattextureeffect_p.h b/src/threed/effects/qglflattextureeffect_p.h
deleted file mode 100644
index 1486d647..00000000
--- a/src/threed/effects/qglflattextureeffect_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLFLATTEXTUREEFFECT_P_H
-#define QGLFLATTEXTUREEFFECT_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.
-//
-
-#include "qglabstracteffect.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLFlatTextureEffectPrivate;
-class QGLFlatDecalTextureEffectPrivate;
-
-class QGLFlatTextureEffect : public QGLAbstractEffect
-{
-public:
- QGLFlatTextureEffect();
- virtual ~QGLFlatTextureEffect();
-
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
-private:
- QScopedPointer<QGLFlatTextureEffectPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLFlatTextureEffect)
- Q_DISABLE_COPY(QGLFlatTextureEffect)
-};
-
-class QGLFlatDecalTextureEffect : public QGLAbstractEffect
-{
-public:
- QGLFlatDecalTextureEffect();
- virtual ~QGLFlatDecalTextureEffect();
-
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
-private:
- QScopedPointer<QGLFlatDecalTextureEffectPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLFlatDecalTextureEffect)
- Q_DISABLE_COPY(QGLFlatDecalTextureEffect)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/effects/qgllitmaterialeffect.cpp b/src/threed/effects/qgllitmaterialeffect.cpp
deleted file mode 100644
index b8ecbd4c..00000000
--- a/src/threed/effects/qgllitmaterialeffect.cpp
+++ /dev/null
@@ -1,571 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgllitmaterialeffect_p.h"
-#include "qglabstracteffect_p.h"
-#include "qglext_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QtCore/qfile.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLLitMaterialEffect
- \since 4.8
- \brief The QGLLitMaterialEffect class provides a standard effect that draws fragments with a lit material.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
-
-static char const litMaterialVertexShader[] =
- "attribute highp vec4 vertex;\n"
- "attribute highp vec3 normal;\n"
- "uniform highp mat4 matrix;\n"
- "uniform highp mat4 modelView;\n"
- "uniform highp mat3 normalMatrix;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = matrix * vertex;\n"
- " highp vec4 tvertex = modelView * vertex;\n"
- " highp vec3 norm = normalize(normalMatrix * normal);\n"
- " qLightVertex(tvertex, norm);\n"
- "}\n";
-
-static char const litMaterialFragmentShader[] =
-#if !defined(QT_OPENGL_ES)
- "varying mediump vec4 qColor;\n"
- "varying mediump vec4 qSecondaryColor;\n"
- "\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = clamp(qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);\n"
- "}\n";
-#else
- "varying mediump vec4 qCombinedColor;\n"
- "\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = qCombinedColor;\n"
- "}\n";
-#endif
-
-// Algorithm from section 2.14.1 of OpenGL 2.1 specification.
-static char const litMaterialLightingShader[] =
-#if !defined(QT_OPENGL_ES)
-"uniform mediump vec3 sdli;\n" // Direction of the light (must be normalized).
-"uniform mediump vec3 pli;\n" // Position of the light
-"uniform mediump float pliw;\n" // 0 for directional, 1 for positional.
-"uniform mediump float srli;\n" // Spotlight exponent for the light
-"uniform mediump float crli;\n" // Spotlight cutoff for the light
-"uniform mediump float ccrli;\n" // Cosine of spotlight cutoff for the light
-"uniform mediump float k0;\n" // Constant attentuation factor for the light
-"uniform mediump float k1;\n" // Linear attentuation factor for the light
-"uniform mediump float k2;\n" // Quadratic attentuation factor for the light
-"uniform mediump vec4 acm[2];\n" // Ambient color of the material and light
-"uniform mediump vec4 dcm[2];\n" // Diffuse color of the material and light
-"uniform mediump vec4 scm[2];\n" // Specular color of the material and light
-"uniform mediump vec4 ecm[2];\n" // Emissive color and ambient scene color
-"uniform mediump float srm[2];\n"// Specular exponent of the material
-"uniform bool viewerAtInfinity;\n" // Light model indicates viewer at infinity
-"uniform bool twoSided;\n" // Light model indicates two-sided lighting
-
-"varying mediump vec4 qColor;\n"
-"varying mediump vec4 qSecondaryColor;\n"
-
-"void qLightVertex(vec4 vertex, vec3 normal)\n"
-"{\n"
-" int i, material;\n"
-" vec3 toEye, toLight, h;\n"
-" float angle, spot, attenuation;\n"
-" vec4 color, scolor;\n"
-" vec4 adcomponent, scomponent;\n"
-
- // Determine which material to use.
-" if (!twoSided || normal.z >= 0.0) {\n"
-" material = 0;\n"
-" } else {\n"
-" material = 1;\n"
-" normal = -normal;\n"
-" }\n"
-
- // Start with the material's emissive color and the ambient scene color,
- // which have been combined into the ecm parameter by the C++ code.
-" color = ecm[material];\n"
-" scolor = vec4(0, 0, 0, 0);\n"
-
- // Vector from the vertex to the eye position (i.e. the origin).
-" if (viewerAtInfinity)\n"
-" toEye = vec3(0, 0, 1);\n"
-" else\n"
-" toEye = normalize(-vertex.xyz);\n"
-
- // Determine the cosine of the angle between the normal and the
- // vector from the vertex to the light.
-" if (pliw == 0.0)\n"
-" toLight = normalize(pli);\n"
-" else\n"
-" toLight = normalize(pli - vertex.xyz);\n"
-" angle = max(dot(normal, toLight), 0.0);\n"
-
- // Calculate the ambient and diffuse light components.
-" adcomponent = acm[material] + angle * dcm[material];\n"
-
- // Calculate the specular light components.
-" if (angle != 0.0) {\n"
-" h = normalize(toLight + toEye);\n"
-" angle = max(dot(normal, h), 0.0);\n"
-" if (srm[material] != 0.0)\n"
-" scomponent = pow(angle, srm[material]) * scm[material];\n"
-" else\n"
-" scomponent = scm[material];\n"
-" } else {\n"
-" scomponent = vec4(0, 0, 0, 0);\n"
-" }\n"
-
- // Apply the spotlight angle and exponent.
-" if (crli != 180.0) {\n"
-" spot = max(dot(normalize(vertex.xyz - pli), sdli), 0.0);\n"
-" if (spot < ccrli) {\n"
-" adcomponent = vec4(0, 0, 0, 0);\n"
-" scomponent = vec4(0, 0, 0, 0);\n"
-" } else {\n"
-" spot = pow(spot, srli);\n"
-" adcomponent *= spot;\n"
-" scomponent *= spot;\n"
-" }\n"
-" }\n"
-
- // Apply attenuation to the colors.
-" if (pliw != 0.0) {\n"
-" attenuation = k0;\n"
-" if (k1 != 0.0 || k2 != 0.0) {\n"
-" float len = length(pli - vertex.xyz);\n"
-" attenuation += k1 * len + k2 * len * len;\n"
-" }\n"
-" color += adcomponent / attenuation;\n"
-" scolor += scomponent / attenuation;\n"
-" } else {\n"
-" color += adcomponent;\n"
-" scolor += scomponent;\n"
-" }\n"
-
- // Generate the final output colors.
-" float alpha = dcm[material].a;\n"
-" qColor = vec4(clamp(color.rgb, 0.0, 1.0), alpha);\n"
-" qSecondaryColor = clamp(scolor, 0.0, 1.0);\n"
-"}\n";
-#else
-"uniform mediump vec3 sdli;\n" // Direction of the light (must be normalized).
-"uniform mediump vec3 pli;\n" // Position of the light
-"uniform mediump float pliw;\n" // 0 for directional, 1 for positional.
-"uniform mediump float srli;\n" // Spotlight exponent for the light
-"uniform mediump float crli;\n" // Spotlight cutoff for the light
-"uniform mediump float ccrli;\n" // Cosine of spotlight cutoff for the light
-"uniform mediump vec4 acm;\n" // Ambient color of the material and light
-"uniform mediump vec4 dcm;\n" // Diffuse color of the material and light
-"uniform mediump vec4 scm;\n" // Specular color of the material and light
-"uniform mediump vec4 ecm;\n" // Emissive color and ambient scene color
-"uniform mediump float srm;\n" // Specular exponent of the material
-"uniform bool viewerAtInfinity;\n" // Light model indicates viewer at infinity
-
-"varying mediump vec4 qColor;\n"
-"varying mediump vec4 qSecondaryColor;\n"
-"varying mediump vec4 qCombinedColor;\n"
-
-"void qLightVertex(vec4 vertex, vec3 normal)\n"
-"{\n"
-" vec3 toEye, toLight, h;\n"
-" float angle, spot;\n"
-" vec4 color, scolor;\n"
-
- // Vector from the vertex to the eye position (i.e. the origin).
-" if (viewerAtInfinity)\n"
-" toEye = vec3(0, 0, 1);\n"
-" else\n"
-" toEye = normalize(-vertex.xyz);\n"
-
- // Determine the cosine of the angle between the normal and the
- // vector from the vertex to the light.
-" if (pliw == 0.0)\n"
-" toLight = normalize(pli);\n"
-" else\n"
-" toLight = normalize(pli - vertex.xyz);\n"
-" angle = max(dot(normal, toLight), 0.0);\n"
-
- // Calculate the ambient and diffuse light components.
-" color = acm + angle * dcm;\n"
-
- // Calculate the specular light components.
-" if (angle != 0.0) {\n"
-" h = normalize(toLight + toEye);\n"
-" angle = max(dot(normal, h), 0.0);\n"
-" if (srm != 0.0)\n"
-" scolor = pow(angle, srm) * scm;\n"
-" else\n"
-" scolor = scm;\n"
-" } else {\n"
-" scolor = vec4(0, 0, 0, 0);\n"
-" }\n"
-
- // Apply the spotlight angle and exponent.
-" if (crli != 180.0) {\n"
-" spot = max(dot(normalize(vertex.xyz - pli), sdli), 0.0);\n"
-" if (spot < ccrli) {\n"
-" color = vec4(0, 0, 0, 0);\n"
-" scolor = vec4(0, 0, 0, 0);\n"
-" } else {\n"
-" spot = pow(spot, srli);\n"
-" color *= spot;\n"
-" scolor *= spot;\n"
-" }\n"
-" }\n"
-
- // Generate the final output colors.
-" color += ecm;\n"
-" float alpha = dcm.a;\n"
- // Note: Normally, the qCombinedColor is ignored, and per-pixel
- // value is calculated.
- // If OPENGL_ES is defined, qColor and qSecondaryColor are ignored,
- // and qCombinedColor is calculated here to speed up the fragment shader.
-" qColor = vec4(clamp(color.rgb, 0.0, 1.0), alpha);\n"
-" qSecondaryColor = clamp(scolor, 0.0, 1.0);\n"
-" qCombinedColor = clamp(qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);\n"
-"}\n";
-#endif
-
-static QByteArray createVertexSource(const char *lighting, const char *extra)
-{
- QByteArray contents(lighting);
- return contents + extra;
-}
-
-static inline QVector4D colorToVector4(const QColor& color)
-{
- return QVector4D(color.redF(), color.greenF(),
- color.blueF(), color.alphaF());
-}
-
-// Combine a material and light color into a single color.
-static inline QVector4D colorToVector4
- (const QColor &color, const QColor &lightColor)
-{
- return QVector4D(color.redF() * lightColor.redF(),
- color.greenF() * lightColor.greenF(),
- color.blueF() * lightColor.blueF(),
- color.alphaF() * lightColor.alphaF());
-}
-
-#endif
-
-class QGLLitMaterialEffectPrivate
-{
-public:
- QGLLitMaterialEffectPrivate()
- : program(0)
- , matrixUniform(-1)
- , modelViewUniform(-1)
- , normalMatrixUniform(-1)
- , textureMode(0)
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- , vertexShader(litMaterialVertexShader)
- , fragmentShader(litMaterialFragmentShader)
-#else
- , vertexShader(0)
- , fragmentShader(0)
-#endif
- , programName(QLatin1String("qt.color.material"))
- , isFixedFunction(false)
- {
- }
-
- QGLShaderProgram *program;
- int matrixUniform;
- int modelViewUniform;
- int normalMatrixUniform;
- GLenum textureMode;
- const char *vertexShader;
- const char *fragmentShader;
- QString programName;
- bool isFixedFunction;
-};
-
-/*!
- Constructs a new lit material effect.
-*/
-QGLLitMaterialEffect::QGLLitMaterialEffect()
- : d_ptr(new QGLLitMaterialEffectPrivate)
-{
-}
-
-/*!
- \internal
-*/
-QGLLitMaterialEffect::QGLLitMaterialEffect
- (GLenum mode, const char *vshader, const char *fshader,
- const QString& programName)
- : d_ptr(new QGLLitMaterialEffectPrivate)
-{
- Q_D(QGLLitMaterialEffect);
- d->textureMode = mode;
- d->vertexShader = vshader;
- d->fragmentShader = fshader;
- d->programName = programName;
-}
-
-/*!
- Destroys this lit material effect.
-*/
-QGLLitMaterialEffect::~QGLLitMaterialEffect()
-{
-}
-
-/*!
- \reimp
-*/
-void QGLLitMaterialEffect::setActive(QGLPainter *painter, bool flag)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- Q_UNUSED(painter);
- Q_D(QGLLitMaterialEffect);
- if (flag) {
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- if (d->textureMode) {
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, d->textureMode);
- glEnable(GL_TEXTURE_2D);
- }
- } else {
- glDisable(GL_LIGHTING);
- glDisable(GL_LIGHT0);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- if (d->textureMode) {
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
- }
-#else
- Q_UNUSED(painter);
- Q_D(QGLLitMaterialEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (painter->isFixedFunction()) {
- d->isFixedFunction = true;
- if (flag) {
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- if (d->textureMode) {
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, d->textureMode);
- glEnable(GL_TEXTURE_2D);
- }
- } else {
- glDisable(GL_LIGHTING);
- glDisable(GL_LIGHT0);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- if (d->textureMode) {
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- }
- }
- return;
- }
-#endif
- QGLShaderProgram *program = painter->cachedProgram(d->programName);
- d->program = program;
- if (!program) {
- if (!flag)
- return;
- program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, createVertexSource(litMaterialLightingShader, d->vertexShader));
- program->addShaderFromSourceCode(QGLShader::Fragment, d->fragmentShader);
- program->bindAttributeLocation("vertex", QGL::Position);
- program->bindAttributeLocation("normal", QGL::Normal);
- if (d->textureMode != 0)
- program->bindAttributeLocation("texcoord", QGL::TextureCoord0);
- if (!program->link()) {
- qWarning("QGLLitMaterialEffect::setActive(): could not link shader program");
- delete program;
- program = 0;
- return;
- }
- painter->setCachedProgram(d->programName, program);
- d->program = program;
- d->matrixUniform = program->uniformLocation("matrix");
- d->modelViewUniform = program->uniformLocation("modelView");
- d->normalMatrixUniform = program->uniformLocation("normalMatrix");
- program->bind();
- if (d->textureMode != 0) {
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::TextureCoord0);
- }
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::Normal);
- } else if (flag) {
- d->matrixUniform = program->uniformLocation("matrix");
- d->modelViewUniform = program->uniformLocation("modelView");
- d->normalMatrixUniform = program->uniformLocation("normalMatrix");
- program->bind();
- if (d->textureMode != 0) {
- program->setUniformValue("tex", 0);
- program->enableAttributeArray(QGL::TextureCoord0);
- }
- program->enableAttributeArray(QGL::Position);
- program->enableAttributeArray(QGL::Normal);
- } else {
- program->disableAttributeArray(QGL::Position);
- program->disableAttributeArray(QGL::Normal);
- if (d->textureMode != 0)
- program->disableAttributeArray(QGL::TextureCoord0);
- program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLLitMaterialEffect::update
- (QGLPainter *painter, QGLPainter::Updates updates)
-{
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateMatrices |
- QGLPainter::UpdateLights |
- QGLPainter::UpdateMaterials));
-#else
- Q_D(QGLLitMaterialEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->isFixedFunction) {
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateMatrices |
- QGLPainter::UpdateLights |
- QGLPainter::UpdateMaterials));
- return;
- }
-#endif
- QGLShaderProgram *program = d->program;
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- program->setUniformValue(d->matrixUniform, painter->combinedMatrix());
- program->setUniformValue(d->modelViewUniform, painter->modelViewMatrix());
- program->setUniformValue(d->normalMatrixUniform, painter->normalMatrix());
- }
- const QGLLightParameters *lparams = painter->mainLight();
- QMatrix4x4 ltransform = painter->mainLightTransform();
- const QGLLightModel *model = painter->lightModel();
- if ((updates & (QGLPainter::UpdateLights | QGLPainter::UpdateMaterials)) != 0) {
- // Set the uniform variables for the light.
- program->setUniformValue
- ("sdli", lparams->eyeSpotDirection(ltransform).normalized());
- QVector4D pli = lparams->eyePosition(ltransform);
- program->setUniformValue("pli", QVector3D(pli.x(), pli.y(), pli.z()));
- program->setUniformValue("pliw", GLfloat(pli.w()));
- program->setUniformValue("srli", GLfloat(lparams->spotExponent()));
- program->setUniformValue("crli", GLfloat(lparams->spotAngle()));
- program->setUniformValue("ccrli", GLfloat(lparams->spotCosAngle()));
-#if !defined(QT_OPENGL_ES)
- // Attenuation is not supported under ES, for performance.
- program->setUniformValue("k0", GLfloat(lparams->constantAttenuation()));
- program->setUniformValue("k1", GLfloat(lparams->linearAttenuation()));
- program->setUniformValue("k2", GLfloat(lparams->quadraticAttenuation()));
-#endif
-
- // Set the uniform variables for the light model.
-#if !defined(QT_OPENGL_ES)
- program->setUniformValue("twoSided", (int)(model->model() == QGLLightModel::TwoSided));
-#endif
- program->setUniformValue("viewerAtInfinity", (int)(model->viewerPosition() == QGLLightModel::ViewerAtInfinity));
-#if !defined(QT_OPENGL_ES)
- if (d->textureMode != 0)
- program->setUniformValue("separateSpecular", (int)(model->colorControl() == QGLLightModel::SeparateSpecularColor));
-#endif
-
- // Set the uniform variables for the front and back materials.
-#if defined(QT_OPENGL_ES)
- static const int MaxMaterials = 1;
-#else
- static const int MaxMaterials = 2;
-#endif
- QVector4D acm[MaxMaterials];
- QVector4D dcm[MaxMaterials];
- QVector4D scm[MaxMaterials];
- QVector4D ecm[MaxMaterials];
- float srm[MaxMaterials];
- const QGLMaterial *mparams = painter->faceMaterial(QGL::FrontFaces);
- acm[0] = colorToVector4(mparams->ambientColor(), lparams->ambientColor());
- dcm[0] = colorToVector4(mparams->diffuseColor(), lparams->diffuseColor());
- scm[0] = colorToVector4(mparams->specularColor(), lparams->specularColor());
- ecm[0] = colorToVector4(mparams->emittedLight()) +
- colorToVector4(mparams->ambientColor(),
- model->ambientSceneColor());
- srm[0] = (float)(mparams->shininess());
-#if !defined(QT_OPENGL_ES)
- mparams = painter->faceMaterial(QGL::BackFaces);
- acm[1] = colorToVector4(mparams->ambientColor(), lparams->ambientColor());
- dcm[1] = colorToVector4(mparams->diffuseColor(), lparams->diffuseColor());
- scm[1] = colorToVector4(mparams->specularColor(), lparams->specularColor());
- ecm[1] = colorToVector4(mparams->emittedLight()) +
- colorToVector4(mparams->ambientColor(),
- model->ambientSceneColor());
- srm[1] = (float)(mparams->shininess());
-#endif
- program->setUniformValueArray("acm", (const GLfloat *)acm, MaxMaterials, 4);
- program->setUniformValueArray("dcm", (const GLfloat *)dcm, MaxMaterials, 4);
- program->setUniformValueArray("scm", (const GLfloat *)scm, MaxMaterials, 4);
- program->setUniformValueArray("ecm", (const GLfloat *)ecm, MaxMaterials, 4);
- program->setUniformValueArray("srm", srm, MaxMaterials, 1);
- }
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qgllitmaterialeffect_p.h b/src/threed/effects/qgllitmaterialeffect_p.h
deleted file mode 100644
index f2afcf4c..00000000
--- a/src/threed/effects/qgllitmaterialeffect_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLLITMATERIALEFFECT_P_H
-#define QGLLITMATERIALEFFECT_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.
-//
-
-#include "qglabstracteffect.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLLitMaterialEffectPrivate;
-
-class QGLLitMaterialEffect : public QGLAbstractEffect
-{
-public:
- QGLLitMaterialEffect();
- virtual ~QGLLitMaterialEffect();
-
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
-protected:
- QGLLitMaterialEffect
- (GLenum mode, const char *vshader, const char *fshader,
- const QString& programName);
-
-private:
- QScopedPointer<QGLLitMaterialEffectPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLLitMaterialEffect)
- Q_DISABLE_COPY(QGLLitMaterialEffect)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/effects/qgllittextureeffect.cpp b/src/threed/effects/qgllittextureeffect.cpp
deleted file mode 100644
index 6d17dce8..00000000
--- a/src/threed/effects/qgllittextureeffect.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgllittextureeffect_p.h"
-#include "qglabstracteffect_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLLitTextureEffect
- \since 4.8
- \brief The QGLLitTextureEffect class provides a standard effect base class for drawing fragments with a lit texture.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-
- \sa QGLLitDecalTextureEffect, QGLLitModulateTextureEffect
-*/
-
-/*!
- \class QGLLitDecalTextureEffect
- \since 4.8
- \brief The QGLLitDecalTextureEffect class provides a standard effect for drawing fragments with a texture decaled over a lit material.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-/*!
- \class QGLLitModulateTextureEffect
- \since 4.8
- \brief The QGLLitModulateTextureEffect class provides a standard effect for drawing fragments with a texture modulated with a lit material.
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-*/
-
-/*!
- \internal
-*/
-QGLLitTextureEffect::QGLLitTextureEffect
- (GLenum mode, const char *vshader, const char *fshader,
- const QString& programName)
- : QGLLitMaterialEffect(mode, vshader, fshader, programName)
-{
-}
-
-/*!
- Destroys this lit texture effect.
-*/
-QGLLitTextureEffect::~QGLLitTextureEffect()
-{
-}
-
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
-
-static char const litTextureVertexShader[] =
- "attribute highp vec4 vertex;\n"
- "attribute highp vec3 normal;\n"
- "attribute highp vec4 texcoord;\n"
- "uniform highp mat4 matrix;\n"
- "uniform highp mat4 modelView;\n"
- "uniform highp mat3 normalMatrix;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = matrix * vertex;\n"
- " highp vec4 tvertex = modelView * vertex;\n"
- " highp vec3 norm = normalize(normalMatrix * normal);\n"
- " qLightVertex(tvertex, norm);\n"
- " qt_TexCoord0 = texcoord;\n"
- "}\n";
-
-static char const litDecalFragmentShader[] =
- "uniform sampler2D tex;\n"
-#if defined(QT_OPENGL_ES)
- "varying mediump vec4 qCombinedColor;\n"
-#else
- "uniform bool separateSpecular;\n"
- "varying mediump vec4 qColor;\n"
- "varying mediump vec4 qSecondaryColor;\n"
-#endif
- "varying highp vec4 qt_TexCoord0;\n"
- "\n"
- "void main(void)\n"
- "{\n"
- " mediump vec4 col = texture2D(tex, qt_TexCoord0.st);\n"
-#if defined(QT_OPENGL_ES)
- " gl_FragColor = vec4(clamp(qCombinedColor.rgb * (1.0 - col.a) + col.rgb * col.a, 0.0, 1.0), qCombinedColor.a);\n"
-#else
- " if (separateSpecular) {\n"
- " gl_FragColor = vec4(clamp(qColor.rgb * (1.0 - col.a) + col.rgb * col.a + qSecondaryColor.xyz, 0.0, 1.0), qColor.a);\n"
- " } else {\n"
- " mediump vec4 lcolor = clamp(qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);\n"
- " gl_FragColor = vec4(clamp(lcolor.rgb * (1.0 - col.a) + col.rgb * col.a, 0.0, 1.0), lcolor.a);\n"
- " }\n"
-#endif
- "}\n";
-
-static char const litModulateFragmentShader[] =
- "uniform sampler2D tex;\n"
-#if defined(QT_OPENGL_ES)
- "varying mediump vec4 qCombinedColor;\n"
-#else
- "uniform bool separateSpecular;\n"
- "varying mediump vec4 qColor;\n"
- "varying mediump vec4 qSecondaryColor;\n"
-#endif
- "varying highp vec4 qt_TexCoord0;\n"
- "\n"
- "void main(void)\n"
- "{\n"
- " mediump vec4 col = texture2D(tex, qt_TexCoord0.st);\n"
-#if defined(QT_OPENGL_ES)
- " gl_FragColor = col * qCombinedColor;\n"
-#else
- " if (separateSpecular) {\n"
- " gl_FragColor = clamp(col * qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);\n"
- " } else {\n"
- " mediump vec4 lcolor = clamp(qColor + vec4(qSecondaryColor.xyz, 0.0), 0.0, 1.0);\n"
- " gl_FragColor = col * lcolor;\n"
- " }\n"
-#endif
- "}\n";
-
-#endif
-
-#ifndef GL_MODULATE
-#define GL_MODULATE 0x2100
-#endif
-#ifndef GL_DECAL
-#define GL_DECAL 0x2101
-#endif
-
-/*!
- Constructs a new lit decal texture effect.
-*/
-QGLLitDecalTextureEffect::QGLLitDecalTextureEffect()
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- : QGLLitTextureEffect(GL_DECAL, 0, 0, QString())
-#else
- : QGLLitTextureEffect(GL_DECAL,
- litTextureVertexShader, litDecalFragmentShader,
- QLatin1String("qt.texture.litdecal"))
-#endif
-{
-}
-
-/*!
- Destroys this lit decal texture effect.
-*/
-QGLLitDecalTextureEffect::~QGLLitDecalTextureEffect()
-{
-}
-
-/*!
- Constructs a new lit modulate texture effect.
-*/
-QGLLitModulateTextureEffect::QGLLitModulateTextureEffect()
-#if defined(QGL_FIXED_FUNCTION_ONLY)
- : QGLLitTextureEffect(GL_MODULATE, 0, 0, QString())
-#else
- : QGLLitTextureEffect(GL_MODULATE,
- litTextureVertexShader, litModulateFragmentShader,
- QLatin1String("qt.texture.litmodulate"))
-#endif
-{
-}
-
-/*!
- Destroys this lit modulate texture effect.
-*/
-QGLLitModulateTextureEffect::~QGLLitModulateTextureEffect()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qgllittextureeffect_p.h b/src/threed/effects/qgllittextureeffect_p.h
deleted file mode 100644
index 2c534ae7..00000000
--- a/src/threed/effects/qgllittextureeffect_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLLITTEXTUREEFFECT_P_H
-#define QGLLITTEXTUREEFFECT_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.
-//
-
-#include "qgllitmaterialeffect_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLLitTextureEffect : public QGLLitMaterialEffect
-{
-public:
- virtual ~QGLLitTextureEffect();
-
-protected:
- QGLLitTextureEffect(GLenum mode, const char *vshader, const char *fshader,
- const QString& programName);
-};
-
-class QGLLitDecalTextureEffect : public QGLLitTextureEffect
-{
-public:
- QGLLitDecalTextureEffect();
- virtual ~QGLLitDecalTextureEffect();
-};
-
-class QGLLitModulateTextureEffect : public QGLLitTextureEffect
-{
-public:
- QGLLitModulateTextureEffect();
- virtual ~QGLLitModulateTextureEffect();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/effects/qglshaderprogrameffect.cpp b/src/threed/effects/qglshaderprogrameffect.cpp
deleted file mode 100644
index 5c771230..00000000
--- a/src/threed/effects/qglshaderprogrameffect.cpp
+++ /dev/null
@@ -1,1131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglshaderprogrameffect.h"
-#include "qglabstracteffect_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QtCore/qfile.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLShaderProgramEffect
- \since 4.8
- \brief The QGLShaderProgramEffect class provides applications with the ability to use shader programs written in GLSL as effects for 3D rendering.
- \ingroup qt3d
- \ingroup qt3d::painting
-
- \section1 Writing portable shaders
-
- Shader programs can be difficult to reuse across OpenGL implementations
- because of varying levels of support for standard vertex attributes and
- uniform variables. In particular, GLSL/ES lacks all of the
- standard variables that are present on desktop OpenGL systems:
- \c{gl_Vertex}, \c{gl_Normal}, \c{gl_Color}, and so on. Desktop OpenGL
- lacks the variable qualifiers \c{highp}, \c{mediump}, and \c{lowp}.
-
- QGLShaderProgramEffect is built on top of
- \l{http://doc.qt.nokia.com/4.7/qglshaderprogram.html}{QGLShaderProgram},
- which makes the process of writing portable shaders easier by
- prefixing all shader programs with the following lines on desktop OpenGL:
-
- \code
- #define highp
- #define mediump
- #define lowp
- \endcode
-
- This makes it possible to run most GLSL/ES shader programs
- on desktop systems. The programmer should also restrict themselves
- to just features that are present in GLSL/ES, and avoid
- standard variable names that only work on the desktop.
-
- QGLShaderProgramEffect also defines some standard attribute and uniform
- variable names that all shaders are expected to use. The following
- sections define these standard names.
-
- \section1 Attributes
-
- QGLShaderProgramEffect provides a standard set of 8 named vertex
- attributes that can be provided via QGLPainter::setVertexBundle():
-
- \table
- \header \o Shader Variable \o Mesh Attribute \o Purpose
- \row \o \c qt_Vertex \o QGL::Position
- \o The primary position of the vertex.
- \row \o \c qt_Normal \o QGL::Normal
- \o The normal at each vertex, for lit material effects.
- \row \o \c qt_Color \o QGL::Color
- \o The color at each vertex, for per-vertex color effects.
- \row \o \c qt_MultiTexCoord0 \o QGL::TextureCoord0
- \o The texture co-ordinate at each vertex for texture unit 0.
- \row \o \c qt_MultiTexCoord1 \o QGL::TextureCoord1
- \o Secondary texture co-ordinate at each vertex.
- \row \o \c qt_MultiTexCoord2 \o QGL::TextureCoord2
- \o Tertiary texture co-ordinate at each vertex.
- \row \o \c qt_Custom0 \o QGL::CustomVertex0
- \o First custom vertex attribute that can be used for any
- user-defined purpose.
- \row \o \c qt_Custom1 \o QGL::CustomVertex1
- \o Second custom vertex attribute that can be used for any
- user-defined purpose.
- \endtable
-
- These attributes may be used in the vertexShader(), as in the following
- example of a simple texture shader:
-
- \code
- attribute highp vec4 qt_Vertex;
- attribute highp vec4 qt_MultiTexCoord0;
- uniform mediump mat4 qt_ModelViewProjectionMatrix;
- varying highp vec4 qt_TexCoord0;
-
- void main(void)
- {
- gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
- qt_TexCoord0 = qt_MultiTexCoord0;
- }
- \endcode
-
- \section1 Uniform variables
-
- QGLShaderProgramEffect provides a standard set of uniform variables for
- common values from the QGLPainter environment:
-
- \table
- \header \o Shader Variable \o Purpose
- \row \o \c qt_ModelViewProjectionMatrix
- \o Combination of the modelview and projection matrices into a
- single 4x4 matrix.
- \row \o \c qt_ModelViewMatrix
- \o Modelview matrix without the projection. This is typically
- used for performing calculations in eye co-ordinates.
- \row \o \c qt_ProjectionMatrix
- \o Projection matrix without the modelview.
- \row \o \c qt_NormalMatrix
- \o Normal matrix, which is the transpose of the inverse of the
- top-left 3x3 part of the modelview matrix. This is typically
- used in lighting calcuations to transform \c qt_Normal.
- \row \o \c qt_WorldMatrix
- \o Modelview matrix without the eye position and orientation
- component. See QGLPainter::worldMatrix() for further
- information.
- \row \o \c qt_Texture0
- \o Sampler corresponding to the texture on unit 0.
- \row \o \c qt_Texture1
- \o Sampler corresponding to the texture on unit 1.
- \row \o \c qt_Texture2
- \o Sampler corresponding to the texture on unit 2.
- \row \o \c qt_Color
- \o Set to the value of the QGLPainter::color() property.
- This is typically used for flat-color shaders that do
- not involve lighting. Note that this is different from
- the \c qt_Color attribute, which provides per-vertex colors.
- \endtable
-
- The above variables are usually declared in the shaders as follows
- (where \c highp may be replaced with \c mediump or \c lowp depending
- upon the shader's precision requirements):
-
- \code
- uniform highp mat4 qt_ModelViewProjectionMatrix;
- uniform highp mat4 qt_ModelViewMatrix;
- uniform highp mat4 qt_ProjectionMatrix;
- uniform highp mat3 qt_NormalMatrix;
- uniform sampler2D qt_Texture0;
- uniform sampler2D qt_Texture1;
- uniform sampler2D qt_Texture2;
- uniform highp vec4 qt_Color;
- \endcode
-
- \section1 Material parameters
-
- QGLShaderProgramEffect will provide information about the front and
- back materials from QGLPainter::faceMaterial() if the
- \c qt_Materials array is present in the shader code.
- The array should be declared as follows:
-
- \code
- struct qt_MaterialParameters {
- mediump vec4 emission;
- mediump vec4 ambient;
- mediump vec4 diffuse;
- mediump vec4 specular;
- mediump float shininess;
- };
- uniform qt_MaterialParameters qt_Materials[2];
- \endcode
-
- The front material will be provided as index 0 and the back
- material will be provided as index 1. If the shader only
- needs a single material, then the \c qt_Material variable
- can be declared instead:
-
- \code
- uniform qt_MaterialParameters qt_Material;
- \endcode
-
- The front material will be provided as the value of \c qt_Material
- and the back material will be ignored.
-
- Note: the \c emission parameter is actually QGLMaterial::emittedLight()
- combined with the QGLLightModel::ambientSceneColor() and
- QGLMaterial::ambientColor(). This helps simplify lighting shaders.
-
- \section1 Lighting parameters
-
- QGLShaderProgramEffect will provide information about the current lights
- specified on the QGLPainter if the \c qt_Lights array is present
- in the shader code. The array should be declared as follows:
-
- \code
- struct qt_LightParameters {
- mediump vec4 ambient;
- mediump vec4 diffuse;
- mediump vec4 specular;
- mediump vec4 position;
- mediump vec3 spotDirection;
- mediump float spotExponent;
- mediump float spotCutoff;
- mediump float spotCosCutoff;
- mediump float constantAttenuation;
- mediump float linearAttenuation;
- mediump float quadraticAttenuation;
- };
- const int qt_MaxLights = 8;
- uniform qt_LightParameters qt_Lights[qt_MaxLights];
- uniform int qt_NumLights;
- \endcode
-
- As shown, up to 8 lights can be supported at once. Usually this is
- more lights than most shaders need, and so the user can change the
- \c qt_MaxLights constant to a smaller value if they wish. Be sure
- to also call setMaximumLights() to tell QGLShaderProgramEffect about
- the new light count limit.
-
- The \c qt_NumLights uniform variable will be set to the actual number
- of lights that are active on the QGLPainter when update() is called.
-
- Because most shaders will only need a single light, the shader can
- declare the \c qt_Light variable instead of the \c qt_Lights array:
-
- \code
- struct qt_SingleLightParameters {
- mediump vec4 position;
- mediump vec3 spotDirection;
- mediump float spotExponent;
- mediump float spotCutoff;
- mediump float spotCosCutoff;
- mediump float constantAttenuation;
- mediump float linearAttenuation;
- mediump float quadraticAttenuation;
- };
- uniform qt_SingleLightParameters qt_Light;
- \endcode
-
- Note that we have omitted the \c ambient, \c diffuse, and \c specular
- colors for the single light. QGLShaderProgramEffect will combine the material
- and light colors ahead of time into \c qt_Material or \c qt_Materials.
- This makes lighting shaders more efficient because they do not have
- to compute \c material_color * \c light_color; just \c material_color
- is sufficient.
-
- \section1 Varying variables
-
- The name and purpose of the varying variables is up to the
- author of the vertex and fragment shaders, but the following names
- are recommended for texture co-ordinates:
-
- \table
- \header \o Varying Variable \o Purpose
- \row \o \c qt_TexCoord0
- \o Texture coordinate for unit 0, copied from the \c qt_MultiTexCoord0
- attribute.
- \row \o \c qt_TexCoord1
- \o Texture coordinate for unit 1, copied from the \c qt_MultiTexCoord1
- attribute.
- \row \o \c qt_TexCoord2
- \o Texture coordinate for unit 2, copied from the \c qt_MultiTexCoord2
- attribute.
- \endtable
-
- \section1 Lighting shader example
-
- The following example demonstrates what a lighting shader that
- uses a single light, a single material, and a texture might look like.
- The shader is quite complex but demonstrates most of the features that
- can be found in the lighting implementation of a fixed-function
- OpenGL pipeline:
-
- \code
- attribute highp vec4 qt_Vertex;
- uniform highp mat4 qt_ModelViewProjectionMatrix;
- attribute highp vec3 qt_Normal;
- uniform highp mat4 qt_ModelViewMatrix;
- uniform highp mat3 qt_NormalMatrix;
- attribute highp vec4 qt_MultiTexCoord0;
- varying highp vec4 qt_TexCoord0;
-
- struct qt_MaterialParameters {
- mediump vec4 emission;
- mediump vec4 ambient;
- mediump vec4 diffuse;
- mediump vec4 specular;
- mediump float shininess;
- };
- uniform qt_MaterialParameters qt_Material;
-
- struct qt_SingleLightParameters {
- mediump vec4 position;
- mediump vec3 spotDirection;
- mediump float spotExponent;
- mediump float spotCutoff;
- mediump float spotCosCutoff;
- mediump float constantAttenuation;
- mediump float linearAttenuation;
- mediump float quadraticAttenuation;
- };
- uniform qt_SingleLightParameters qt_Light;
-
- varying mediump vec4 litColor;
- varying mediump vec4 litSecondaryColor;
-
- void main(void)
- {
- gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
- gTexCoord0 = qt_MultiTexCoord0;
-
- // Calculate the vertex and normal to use for lighting calculations.
- highp vec4 vertex = qt_ModelViewMatrix * qt_Vertex;
- highp vec3 normal = normalize(qt_NormalMatrix * qt_Normal);
-
- // Start with the material's emissive color and the ambient scene color,
- // which have been combined into the emission parameter.
- vec4 color = ggl_Material.emission;
-
- // Viewer is at infinity.
- vec3 toEye = vec3(0, 0, 1);
-
- // Determine the angle between the normal and the light direction.
- vec4 pli = qt_Light.position;
- vec3 toLight;
- if (pli.w == 0.0)
- toLight = normalize(pli.xyz);
- else
- toLight = normalize(pli.xyz - vertex.xyz);
- float angle = max(dot(normal, toLight), 0.0);
-
- // Calculate the ambient and diffuse light components.
- vec4 adcomponent = qt_Material.ambient + angle * qt_Material.diffuse;
-
- // Calculate the specular light components.
- vec4 scomponent;
- if (angle != 0.0) {
- vec3 h = normalize(toLight + toEye);
- angle = max(dot(normal, h), 0.0);
- float srm = qt_Material.shininess;
- vec4 scm = qt_Material.specular;
- if (srm != 0.0)
- scomponent = pow(angle, srm) * scm;
- else
- scomponent = scm;
- } else {
- scomponent = vec4(0, 0, 0, 0);
- }
-
- // Apply the spotlight angle and exponent.
- if (qt_Light.spotCutoff != 180.0) {
- float spot = max(dot(normalize(vertex.xyz - pli.xyz),
- qt_Light.spotDirection), 0.0);
- if (spot < qt_Light.spotCosCutoff) {
- adcomponent = vec4(0, 0, 0, 0);
- scomponent = vec4(0, 0, 0, 0);
- } else {
- spot = pow(spot, qt_Light.spotExponent);
- adcomponent *= spot;
- scomponent *= spot;
- }
- }
-
- // Apply attenuation to the colors.
- if (pli.w != 0.0) {
- float attenuation = qt_Light.constantAttenuation;
- float k1 = qt_Light.linearAttenuation;
- float k2 = qt_Light.quadraticAttenuation;
- if (k1 != 0.0 || k2 != 0.0) {
- float len = length(pli.xyz - vertex.xyz);
- attenuation += k1 * len + k2 * len * len;
- }
- color += adcomponent / attenuation;
- scolor += scomponent / attenuation;
- } else {
- color += adcomponent;
- scolor += scomponent;
- }
-
- // Generate the final output colors to pass to the fragment shader.
- float alpha = qt_Material.diffuse.a;
- litColor = vec4(clamp(color.rgb, 0.0, 1.0), alpha);
- litSecondaryColor = vec4(clamp(scolor.rgb, 0.0, 1.0), 0.0);
- }
- \endcode
-
- The corresponding fragment shader is as follows:
-
- \code
- varying mediump vec4 litColor;
- varying mediump vec4 litSecondaryColor;
- varying highp vec4 qt_TexCoord0;
-
- void main(void)
- {
- vec4 color = litColor * texture2D(qt_Texture0, qt_TexCoord0.st);
- gl_FragColor = clamp(color + litSecondaryColor, 0.0, 1.0);
- }
- \endcode
-
- \section1 Fixed function operation
-
- If the OpenGL implementation does not support shaders, then
- QGLShaderProgramEffect will fall back to a flat color effect based
- on QGLPainter::color(). It is recommended that the application
- consult QGLPainter::isFixedFunction() to determine if some
- other effect should be used instead.
-*/
-
-class QGLShaderProgramEffectPrivate
-{
-public:
- QGLShaderProgramEffectPrivate()
- : geometryInputType(GL_TRIANGLE_STRIP)
- , geometryOutputType(GL_TRIANGLE_STRIP)
- , maximumLights(8)
- , attributes(0)
- , regenerate(true)
- , fixedFunction(false)
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- , program(0)
- , matrix(-1)
- , mvMatrix(-1)
- , projMatrix(-1)
- , normalMatrix(-1)
- , worldMatrix(-1)
- , texture0(-1)
- , texture1(-1)
- , texture2(-1)
- , color(-1)
- , numLights(-1)
- , haveLight(0)
- , haveLights(0)
- , haveMaterial(0)
- , haveMaterials(0)
-#endif
- {
- }
- ~QGLShaderProgramEffectPrivate()
- {
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- delete program;
-#endif
- }
-
- QByteArray vertexShader;
- QByteArray fragmentShader;
- QByteArray geometryShader;
- GLenum geometryInputType;
- GLenum geometryOutputType;
- int maximumLights;
- int attributes;
- bool regenerate;
- bool fixedFunction;
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- QGLShaderProgram *program;
- int matrix;
- int mvMatrix;
- int projMatrix;
- int normalMatrix;
- int worldMatrix;
- int texture0;
- int texture1;
- int texture2;
- int color;
- int numLights;
- int haveLight : 1;
- int haveLights : 1;
- int haveMaterial : 1;
- int haveMaterials : 1;
-
- void setUniformValue
- (const char *array, int index, const char *field, GLfloat v);
- void setUniformValue
- (const char *array, int index, const char *field, const QVector3D &v);
- void setUniformValue
- (const char *array, int index, const char *field, const QVector4D &v);
- void setUniformValue
- (const char *array, int index, const char *field, const QColor &v);
-
- void setLight
- (const QGLLightParameters *lparams, const QMatrix4x4 &ltransform,
- const char *array, int index);
- void setMaterial
- (const QGLMaterial *mparams, const QGLLightModel *model,
- const QGLLightParameters *lparams, const char *array, int index);
-#endif
-};
-
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
-
-void QGLShaderProgramEffectPrivate::setUniformValue
- (const char *array, int index, const char *field, GLfloat v)
-{
- char name[128];
- if (index >= 0)
- qsnprintf(name, sizeof(name), "%s[%d].%s", array, index, field);
- else
- qsnprintf(name, sizeof(name), "%s.%s", array, field);
- program->setUniformValue(name, v);
-}
-
-void QGLShaderProgramEffectPrivate::setUniformValue
- (const char *array, int index, const char *field, const QVector3D &v)
-{
- char name[128];
- if (index >= 0)
- qsnprintf(name, sizeof(name), "%s[%d].%s", array, index, field);
- else
- qsnprintf(name, sizeof(name), "%s.%s", array, field);
- program->setUniformValue(name, v);
-}
-
-void QGLShaderProgramEffectPrivate::setUniformValue
- (const char *array, int index, const char *field, const QVector4D &v)
-{
- char name[128];
- if (index >= 0)
- qsnprintf(name, sizeof(name), "%s[%d].%s", array, index, field);
- else
- qsnprintf(name, sizeof(name), "%s.%s", array, field);
- program->setUniformValue(name, v);
-}
-
-void QGLShaderProgramEffectPrivate::setUniformValue
- (const char *array, int index, const char *field, const QColor &v)
-{
- char name[128];
- if (index >= 0)
- qsnprintf(name, sizeof(name), "%s[%d].%s", array, index, field);
- else
- qsnprintf(name, sizeof(name), "%s.%s", array, field);
- program->setUniformValue(name, v);
-}
-
-void QGLShaderProgramEffectPrivate::setLight
- (const QGLLightParameters *lparams, const QMatrix4x4 &ltransform,
- const char *array, int index)
-{
- if (index >= 0) {
- // Single lights embed the color values into the material.
- setUniformValue(array, index, "ambient", lparams->ambientColor());
- setUniformValue(array, index, "diffuse", lparams->diffuseColor());
- setUniformValue(array, index, "specular", lparams->specularColor());
- }
- setUniformValue
- (array, index, "position", lparams->eyePosition(ltransform));
- setUniformValue
- (array, index, "spotDirection",
- lparams->eyeSpotDirection(ltransform).normalized());
- setUniformValue
- (array, index, "spotExponent", GLfloat(lparams->spotExponent()));
- setUniformValue
- (array, index, "spotCutoff", GLfloat(lparams->spotAngle()));
- setUniformValue
- (array, index, "spotCosCutoff", GLfloat(lparams->spotCosAngle()));
- setUniformValue
- (array, index, "constantAttenuation",
- GLfloat(lparams->constantAttenuation()));
- setUniformValue
- (array, index, "linearAttenuation",
- GLfloat(lparams->linearAttenuation()));
- setUniformValue
- (array, index, "quadraticAttenuation",
- GLfloat(lparams->quadraticAttenuation()));
-}
-
-static inline QVector4D colorToVector4(const QColor& color)
-{
- return QVector4D(color.redF(), color.greenF(),
- color.blueF(), color.alphaF());
-}
-
-// Combine a material and light color into a single color.
-static inline QVector4D colorToVector4
- (const QColor &color, const QColor &lightColor)
-{
- return QVector4D(color.redF() * lightColor.redF(),
- color.greenF() * lightColor.greenF(),
- color.blueF() * lightColor.blueF(),
- color.alphaF() * lightColor.alphaF());
-}
-
-void QGLShaderProgramEffectPrivate::setMaterial
- (const QGLMaterial *mparams, const QGLLightModel *model,
- const QGLLightParameters *lparams, const char *array, int index)
-{
- if (lparams) {
- setUniformValue
- (array, index, "ambient",
- colorToVector4(mparams->ambientColor(), lparams->ambientColor()));
- setUniformValue
- (array, index, "diffuse",
- colorToVector4(mparams->diffuseColor(), lparams->diffuseColor()));
- setUniformValue
- (array, index, "specular",
- colorToVector4(mparams->specularColor(), lparams->specularColor()));
- } else {
- setUniformValue
- (array, index, "ambient", mparams->ambientColor());
- setUniformValue
- (array, index, "diffuse", mparams->diffuseColor());
- setUniformValue
- (array, index, "specular", mparams->specularColor());
- }
- setUniformValue
- (array, index, "emission",
- colorToVector4(mparams->emittedLight()) +
- colorToVector4(mparams->ambientColor(), model->ambientSceneColor()));
- setUniformValue
- (array, index, "shininess", GLfloat(mparams->shininess()));
-}
-
-#endif // !QGL_FIXED_FUNCTION_ONLY
-
-/*!
- Constructs a new shader program effect. This constructor is typically
- followed by calls to setVertexShader() and setFragmentShader().
-
- Note that a shader program effect will be bound to the QGLContext that
- is current when setActive() is called for the first time. After that,
- the effect can only be used with that context or any other QGLContext
- that shares with it.
-*/
-QGLShaderProgramEffect::QGLShaderProgramEffect()
- : d_ptr(new QGLShaderProgramEffectPrivate)
-{
-}
-
-/*!
- Destroys this shader program effect.
-*/
-QGLShaderProgramEffect::~QGLShaderProgramEffect()
-{
-}
-
-/*!
- \reimp
-*/
-void QGLShaderProgramEffect::setActive(QGLPainter *painter, bool flag)
-{
- Q_D(QGLShaderProgramEffect);
-
-#if !defined(QGL_SHADERS_ONLY)
- d->fixedFunction = painter->isFixedFunction();
- if (d->fixedFunction) {
- // Fixed function emulation is flat color only.
- if (flag)
- glEnableClientState(GL_VERTEX_ARRAY);
- else
- glDisableClientState(GL_VERTEX_ARRAY);
- return;
- }
-#endif
-
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- static const char *const attributes[] = {
- "qt_Vertex",
- "qt_Normal",
- "qt_Color",
- "qt_MultiTexCoord0",
- "qt_MultiTexCoord1",
- "qt_MultiTexCoord2",
- "qt_Custom0",
- "qt_Custom1"
- };
- const int numAttributes = 8;
- Q_UNUSED(painter);
- int attr;
- if (d->regenerate) {
- // The shader source has changed since the last call to setActive().
- delete d->program;
- d->program = 0;
- d->regenerate = false;
- }
- if (!d->program) {
- if (!flag)
- return;
- if (d->vertexShader.isEmpty() || d->fragmentShader.isEmpty())
- return;
-
- d->program = new QGLShaderProgram();
- d->program->addShaderFromSourceCode
- (QGLShader::Vertex, d->vertexShader);
- d->program->addShaderFromSourceCode
- (QGLShader::Fragment, d->fragmentShader);
- if (!d->geometryShader.isEmpty())
- {
- d->program->addShaderFromSourceCode
- (QGLShader::Geometry, d->geometryShader);
- d->program->setGeometryInputType(d->geometryInputType);
- d->program->setGeometryOutputType(d->geometryOutputType);
-
- }
-
- if (beforeLink()) {
- for (attr = 0; attr < numAttributes; ++attr)
- d->program->bindAttributeLocation(attributes[attr], attr);
- }
- if (!d->program->link()) {
- qWarning("QGLShaderProgramEffect::setActive(): could not link shader program");
- delete d->program;
- d->program = 0;
- return;
- }
- afterLink();
- d->attributes = 0;
- for (attr = 0; attr < numAttributes; ++attr) {
- // Determine which attributes were actually present in the program.
- if (d->program->attributeLocation(attributes[attr]) != -1)
- d->attributes |= (1 << attr);
- }
- if (d->program->attributeLocation("qgl_Vertex") != -1)
- qWarning("QGLShaderProgramEffect: qgl_Vertex no longer supported; use qt_Vertex instead");
- d->matrix = d->program->uniformLocation("qt_ModelViewProjectionMatrix");
- d->mvMatrix = d->program->uniformLocation("qt_ModelViewMatrix");
- d->projMatrix = d->program->uniformLocation("qt_ProjectionMatrix");
- d->normalMatrix = d->program->uniformLocation("qt_NormalMatrix");
- d->worldMatrix = d->program->uniformLocation("qt_WorldMatrix");
- d->texture0 = d->program->uniformLocation("qt_Texture0");
- d->texture1 = d->program->uniformLocation("qt_Texture1");
- d->texture2 = d->program->uniformLocation("qt_Texture2");
- d->color = d->program->uniformLocation("qt_Color");
- d->numLights = d->program->uniformLocation("qt_NumLights");
- d->haveLight =
- (d->program->uniformLocation("qt_Light.position") != -1);
- d->haveLights =
- (d->program->uniformLocation("qt_Lights[0].position") != -1);
- d->haveMaterial =
- (d->program->uniformLocation("qt_Material.ambient") != -1) ||
- (d->program->uniformLocation("qt_Material.diffuse") != -1) ||
- (d->program->uniformLocation("qt_Material.specular") != -1) ||
- (d->program->uniformLocation("qt_Material.emission") != -1);
- d->haveMaterials =
- (d->program->uniformLocation("qt_Material[0].ambient") != -1) ||
- (d->program->uniformLocation("qt_Material[0].diffuse") != -1) ||
- (d->program->uniformLocation("qt_Material[0].specular") != -1) ||
- (d->program->uniformLocation("qt_Material[0].emission") != -1);
- }
- if (flag) {
- d->program->bind();
- for (attr = 0; attr < numAttributes; ++attr) {
- if ((d->attributes & (1 << attr)) == 0)
- continue;
- d->program->enableAttributeArray(attr);
- }
- if (d->texture0 != -1)
- d->program->setUniformValue(d->texture0, 0);
- if (d->texture1 != -1)
- d->program->setUniformValue(d->texture1, 1);
- if (d->texture2 != -1)
- d->program->setUniformValue(d->texture2, 2);
- } else {
- for (attr = 0; attr < int(QGL::UserVertex); ++attr) {
- if ((d->attributes & (1 << attr)) != 0)
- d->program->disableAttributeArray(attr);
- }
- d->program->release();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGLShaderProgramEffect::update(QGLPainter *painter, QGLPainter::Updates updates)
-{
- Q_D(QGLShaderProgramEffect);
-#if !defined(QGL_SHADERS_ONLY)
- if (d->fixedFunction) {
- // Fixed function emulation is flat color only.
- painter->updateFixedFunction
- (updates & (QGLPainter::UpdateColor | QGLPainter::UpdateMatrices));
- return;
- }
-#endif
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- if ((updates & QGLPainter::UpdateColor) != 0 && d->color != -1)
- d->program->setUniformValue(d->color, painter->color());
- if ((updates & QGLPainter::UpdateMatrices) != 0) {
- if (d->matrix != -1)
- d->program->setUniformValue(d->matrix, painter->combinedMatrix());
- }
- if ((updates & QGLPainter::UpdateModelViewMatrix) != 0) {
- if (d->mvMatrix != -1)
- d->program->setUniformValue(d->mvMatrix, painter->modelViewMatrix());
- if (d->normalMatrix != -1)
- d->program->setUniformValue(d->normalMatrix, painter->normalMatrix());
- if (d->worldMatrix != -1)
- d->program->setUniformValue(d->worldMatrix, painter->worldMatrix());
- }
- if ((updates & QGLPainter::UpdateProjectionMatrix) != 0) {
- if (d->projMatrix != -1)
- d->program->setUniformValue(d->projMatrix, painter->projectionMatrix());
- }
- if ((updates & QGLPainter::UpdateLights) != 0) {
- if (d->haveLight) {
- // Only one light needed so make it the main light.
- d->setLight(painter->mainLight(), painter->mainLightTransform(),
- "qt_Light", -1);
- } else if (d->haveLights) {
- // Shader supports multiple light sources.
- int numLights = 0;
- int maxLightId = painter->maximumLightId();
- if (maxLightId < 0) {
- // No lights - re-enable the main light so we have something.
- painter->mainLight();
- maxLightId = 0;
- }
- for (int lightId = 0; lightId <= maxLightId; ++lightId) {
- // Is this light currently enabled?
- const QGLLightParameters *lparams = painter->light(lightId);
- if (!lparams)
- continue;
-
- // Set the parameters for the next shader light number.
- d->setLight(lparams, painter->lightTransform(lightId),
- "qt_Lights", numLights);
-
- // Bail out if we've hit the maximum shader light limit.
- ++numLights;
- if (numLights >= d->maximumLights)
- break;
- }
- if (d->numLights != -1)
- d->program->setUniformValue(d->numLights, numLights);
- }
- }
- if ((updates & QGLPainter::UpdateMaterials) != 0 ||
- ((updates & QGLPainter::UpdateLights) != 0 && d->haveLight)) {
- if (d->haveLight) {
- // For a single light source, combine the light colors
- // into the material colors.
- if (d->haveMaterial) {
- d->setMaterial(painter->faceMaterial(QGL::FrontFaces),
- painter->lightModel(), painter->mainLight(),
- "qt_Material", -1);
- } else if (d->haveMaterials) {
- d->setMaterial(painter->faceMaterial(QGL::FrontFaces),
- painter->lightModel(), painter->mainLight(),
- "qt_Materials", 0);
- d->setMaterial(painter->faceMaterial(QGL::BackFaces),
- painter->lightModel(), painter->mainLight(),
- "qt_Materials", 1);
- }
- } else {
- // Multiple light sources, so light colors are separate.
- if (d->haveMaterial) {
- d->setMaterial(painter->faceMaterial(QGL::FrontFaces),
- painter->lightModel(), 0, "qt_Material", -1);
- } else if (d->haveMaterials) {
- d->setMaterial(painter->faceMaterial(QGL::FrontFaces),
- painter->lightModel(), 0, "qt_Materials", 0);
- d->setMaterial(painter->faceMaterial(QGL::BackFaces),
- painter->lightModel(), 0, "qt_Materials", 1);
- }
- }
- }
-#endif
-}
-
-/*!
- Returns the source code for the vertex shader.
-
- \sa setVertexShader(), geometryShader(), fragmentShader(), setVertexShaderFromFile()
-*/
-QByteArray QGLShaderProgramEffect::vertexShader() const
-{
- Q_D(const QGLShaderProgramEffect);
- return d->vertexShader;
-}
-
-/*!
- Sets the \a source code for the vertex shader.
-
- \sa vertexShader(), setGeometryShader(), setFragmentShader(), setVertexShaderFromFile()
-*/
-void QGLShaderProgramEffect::setVertexShader(const QByteArray &source)
-{
- Q_D(QGLShaderProgramEffect);
- d->vertexShader = source;
- d->regenerate = true;
-}
-
-/*!
- Sets the source code for the vertex shader to the contents
- of \a fileName.
-
- \sa setVertexShader(), setGeometryShaderFromFile(), setFragmentShaderFromFile()
-*/
-void QGLShaderProgramEffect::setVertexShaderFromFile(const QString &fileName)
-{
- Q_D(QGLShaderProgramEffect);
- QFile file(fileName);
- if (file.open(QIODevice::ReadOnly)) {
- d->vertexShader = file.readAll();
- d->regenerate = true;
- } else {
- qWarning() << "QGLShaderProgramEffect::setVertexShaderFromFile: could not open " << fileName;
- }
-}
-
-/*!
- Returns the source code for the geometry shader.
-
- \sa setGeometryShader(), fragmentShader(), setGeometryShaderFromFile()
-*/
-QByteArray QGLShaderProgramEffect::geometryShader() const
-{
- Q_D(const QGLShaderProgramEffect);
- return d->geometryShader;
-}
-
-/*!
- Sets the \a source code for the geometry shader.
-
- \sa geometryShader(), setFragmentShader(), setGeometryShaderFromFile()
-*/
-void QGLShaderProgramEffect::setGeometryShader(const QByteArray &source)
-{
- Q_D(QGLShaderProgramEffect);
- d->geometryShader = source;
- d->regenerate = true;
-}
-
-/*!
- Sets the source code for the geometry shader to the contents
- of \a fileName.
-
- \sa setGeometryShader(), setFragmentShaderFromFile()
-*/
-void QGLShaderProgramEffect::setGeometryShaderFromFile(const QString &fileName)
-{
- Q_D(QGLShaderProgramEffect);
- QFile file(fileName);
- if (file.open(QIODevice::ReadOnly)) {
- d->geometryShader = file.readAll();
- d->regenerate = true;
- } else {
- qWarning() << "QGLShaderProgramEffect::setGeometryShaderFromFile: could not open " << fileName;
- }
-}
-
-/*!
- Returns the source code for the fragment shader.
-
- \sa setFragmentShader(), vertexShader(), geometryShader()
-*/
-QByteArray QGLShaderProgramEffect::fragmentShader() const
-{
- Q_D(const QGLShaderProgramEffect);
- return d->fragmentShader;
-}
-
-/*!
- Sets the source code for the fragment shader to the contents
- of \a fileName.
-
- \sa setFragmentShader(), setVertexShaderFromFile(), setGeometryShaderFromFile()
-*/
-void QGLShaderProgramEffect::setFragmentShaderFromFile(const QString &fileName)
-{
- Q_D(QGLShaderProgramEffect);
- QFile file(fileName);
- if (file.open(QIODevice::ReadOnly)) {
- d->fragmentShader = file.readAll();
- d->regenerate = true;
- } else {
- qWarning() << "QGLShaderProgramEffect::setFragmentShaderFromFile: could not open " << fileName;
- }
-}
-
-/*!
- Sets the \a source code for the fragment shader.
-
- \sa fragmentShader(), setVertexShader(), setGeometryShader()
-*/
-void QGLShaderProgramEffect::setFragmentShader(const QByteArray &source)
-{
- Q_D(QGLShaderProgramEffect);
- d->fragmentShader = source;
- d->regenerate = true;
-}
-
-/*!
- Sets the type of primitive the program's geometry shader is expecting to
- recieve from the vertex shader. The default value is GL_TRIANGLE_STRIP.
-
- If the program has no geometry shader, this has no effect.
-*/
-void QGLShaderProgramEffect::setGeometryInputType(GLenum drawingMode)
-{
- Q_D(QGLShaderProgramEffect);
- d->geometryInputType = drawingMode;
-}
-
-/*!
- Sets what sort of primitives the program's geometry shader will produce.
- The default value is GL_TRIANGLE_STRIP.
-
- If the program has no geometry shader, this has no effect.
-*/
-void QGLShaderProgramEffect::setGeometryOutputType(GLenum drawingMode)
-{
- Q_D(QGLShaderProgramEffect);
- d->geometryOutputType = drawingMode;
-}
-
-/*!
- Returns the type of primitives this program's geometry shader is expecting.
-*/
-GLenum QGLShaderProgramEffect::geometryInputType()
-{
- Q_D(QGLShaderProgramEffect);
- return d->geometryInputType;
-}
-
-/*!
- Returns the type of primitive this program's geometry shader will produce.
-*/
-GLenum QGLShaderProgramEffect::geometryOutputType()
-{
- Q_D(QGLShaderProgramEffect);
- return d->geometryOutputType;
-}
-
-/*!
- Returns the maximum number of lights that are supported by this
- shader program effect. The default value is 8.
-
- The actual number of lights will be provided to the vertexShader()
- as the \c{qt_NumLights} uniform variable, which will always be
- less than or equal to maximumLights().
-
- \sa setMaximumLights()
-*/
-int QGLShaderProgramEffect::maximumLights() const
-{
- Q_D(const QGLShaderProgramEffect);
- return d->maximumLights;
-}
-
-/*!
- Sets the maximum number of lights that are supported by this
- shader program effect to \a value.
-
- \sa maximumLights()
-*/
-void QGLShaderProgramEffect::setMaximumLights(int value)
-{
- Q_D(QGLShaderProgramEffect);
- d->maximumLights = value;
-}
-
-/*!
- Returns the shader program object that was created for this effect;
- null if setActive() has not been called yet.
-
- This function can be used by the application to adjust custom
- uniform variables after the effect is activated on a QGLPainter:
-
- \code
- painter.setUserEffect(effect);
- effect->program()->setUniformValue("springiness", GLfloat(0.5f));
- \endcode
-*/
-QGLShaderProgram *QGLShaderProgramEffect::program() const
-{
-#if !defined(QGL_FIXED_FUNCTION_ONLY)
- Q_D(const QGLShaderProgramEffect);
- return d->program;
-#else
- return 0;
-#endif
-}
-
-/*!
- Called by setActive() just before the program() is linked.
- Returns true if the standard vertex attributes should be bound
- by calls to QGLShaderProgram::bindAttributeLocation(). Returns
- false if the subclass has already bound the attributes.
-
- This function can be overridden by subclasses to alter the
- vertex attribute bindings, or to add additional shader stages
- to program().
-
- \sa afterLink()
-*/
-bool QGLShaderProgramEffect::beforeLink()
-{
- return true;
-}
-
-/*!
- Called by setActive() just after the program() is linked.
- The default implementation does nothing.
-
- This function can be overridden by subclasses to resolve uniform
- variable locations and cache them for later use in update().
-
- \sa beforeLink()
-*/
-void QGLShaderProgramEffect::afterLink()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/effects/qglshaderprogrameffect.h b/src/threed/effects/qglshaderprogrameffect.h
deleted file mode 100644
index 4098a52e..00000000
--- a/src/threed/effects/qglshaderprogrameffect.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSHADERPROGRAMEFFECT_H
-#define QGLSHADERPROGRAMEFFECT_H
-
-#include "qglabstracteffect.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLShaderProgramEffectPrivate;
-class QGLShaderProgram;
-
-class Q_QT3D_EXPORT QGLShaderProgramEffect : public QGLAbstractEffect
-{
-public:
- QGLShaderProgramEffect();
- virtual ~QGLShaderProgramEffect();
-
- void setActive(QGLPainter *painter, bool flag);
- void update(QGLPainter *painter, QGLPainter::Updates updates);
-
- QByteArray vertexShader() const;
- void setVertexShader(const QByteArray &source);
- void setVertexShaderFromFile(const QString &fileName);
-
- QByteArray geometryShader() const;
- void setGeometryShader(const QByteArray &source);
- void setGeometryShaderFromFile(const QString &fileName);
-
- QByteArray fragmentShader() const;
- void setFragmentShader(const QByteArray &source);
- void setFragmentShaderFromFile(const QString &fileName);
-
- void setGeometryInputType(GLenum drawingMode);
- void setGeometryOutputType(GLenum drawingMode);
- GLenum geometryInputType();
- GLenum geometryOutputType();
-
- int maximumLights() const;
- void setMaximumLights(int value);
-
- QGLShaderProgram *program() const;
-
-protected:
- virtual bool beforeLink();
- virtual void afterLink();
-
-private:
- QScopedPointer<QGLShaderProgramEffectPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGLShaderProgramEffect)
- Q_DECLARE_PRIVATE(QGLShaderProgramEffect)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/geometry.pri b/src/threed/geometry/geometry.pri
deleted file mode 100644
index 7f6be75c..00000000
--- a/src/threed/geometry/geometry.pri
+++ /dev/null
@@ -1,28 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += geometry/qglcube.h \
- geometry/qglsphere.h \
- geometry/qgeometrydata.h \
- geometry/qlogicalvertex.h \
- geometry/qglbuilder.h \
- geometry/qglbezierpatches.h \
- geometry/qglmaterialcollection.h \
- geometry/qglteapot.h \
- geometry/qglcylinder.h \
- geometry/qgldome.h
-SOURCES += qglcube.cpp \
- qglsphere.cpp \
- qgeometrydata.cpp \
- qglbuilder.cpp \
- qglsection.cpp \
- qglbezierpatches.cpp \
- qglmaterialcollection.cpp \
- qglteapot.cpp \
- qlogicalvertex.cpp \
- qglcylinder.cpp \
- qgldome.cpp
-PRIVATE_HEADERS += qglteapot_data_p.h \
- qglbuilder_p.h \
- qglsection_p.h \
- qglteapot_data_p.h \
- qvector_utils_p.h
diff --git a/src/threed/geometry/qgeometrydata.cpp b/src/threed/geometry/qgeometrydata.cpp
deleted file mode 100644
index 6ee4e181..00000000
--- a/src/threed/geometry/qgeometrydata.cpp
+++ /dev/null
@@ -1,2030 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgeometrydata.h"
-#include "qlogicalvertex.h"
-#include "qglpainter.h"
-
-#include <QtOpenGL/qgl.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeometryData
- \brief The QGeometryData class encapsulates sets of geometry data.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The QGeometryData class encloses a number of data arrays
- that model most typical vertex data needs. The class provides a
- store for all of the data types in the QGL::VertexAttribute enumeration.
-
- \table
- \header
- \o QGL::VertexAttribute
- \o QGeometryData functions
- \row
- \o QGL::Position
- \o appendVertex(), vertex(), vertices()
- \row
- \o QGL::Normal
- \o appendNormal(), normal(), normals()
- \row
- \o QGL::Color
- \o appendColor(), colorRef(), colors()
- \row
- \o QGL::TextureCoord0 - QGL::TextureCoord3
- \o appendTexCoord(), texCoordRef(), texCoords()
- \row
- \o QGL::CustomVertex0 - QGL::CustomVertex1, QGL::UserVertex
- \o appendAttribute(), vector3DAttribute(), attributes()
- \endtable
-
- Additionally the class provides the following features:
- \list
- \o appendVertex() for adding a QLogicalVertex()
- \o logicalVertexAt() for return the data at an index as a QLogicalVertex()
- \o hasField() to find if a particular data type is present
- \o normalizeNormals() to reduce all normal vectors to unit length
- \o boundingBox() to find the bounds of the geometry
- \endlist
-
- It is up to the user of a QGeometryData instance to ensure that the
- data has an equal number of items in each field. For example, if five
- vertices are added and only two normals are added, the logical vertex at
- position 3 will be corrupt, since it does not have a normal.
-
- While data is being accumulated the counts of different fields will vary,
- since it may be convenient to add several vertices, then several normals,
- colors or attributes at a time. However when a logical vertex is
- constructed or when the data is sent to the GPU, counts of all fields
- must be equal.
-
- QGeometryData uses explicit sharing with lazy creation of internal
- data so that code like:
- \code
- QGeometryData myData;
- if (processed)
- myData = processedData();
- \endcode
- is very inexpensive, since the first declaration and initialization
- does not cause internal data to be created (only to be overwritten by the
- assignment operation).
-
- Since QGeometryData is explicitly shared, variables of type
- QGeometryData behave like references, and the underlying data is modified
- by calling a non-const function on any variable which shares that data.
-
- To force an explicit copy call the detach() function.
-*/
-
-/*!
- \typedef QGL::IndexArray
-
- This is a convenience for either QArray<ushort> (OpenGL/ES) or
- QArray<int> (desktop OpenGL).
-*/
-
-class QGeometryDataPrivate
-{
-public:
- QGeometryDataPrivate();
- ~QGeometryDataPrivate();
- QGeometryDataPrivate *clone() const;
-
- QBasicAtomicInt ref;
-
- QVector3DArray vertices;
- QVector3DArray normals;
- QArray<QColor4ub> colors;
- QList<QCustomDataArray> attributes;
- QList<QVector2DArray> textures;
- QGL::IndexArray indices;
- QGLVertexBundle vertexBundle;
- QGLIndexBuffer indexBuffer;
- bool uploadsViable;
- bool modified;
- QBox3D bb;
- static const int ATTR_CNT = 32;
- quint32 fields;
- qint8 key[ATTR_CNT];
- quint8 size[ATTR_CNT];
- int count;
- int reserved;
- bool boxValid;
- QGeometryData::BufferStrategy bufferStrategy;
-};
-
-QGeometryDataPrivate::QGeometryDataPrivate()
- : uploadsViable(true)
- , modified(false)
- , fields(0)
- , count(0)
- , reserved(-1)
- , boxValid(true)
- , bufferStrategy(QGeometryData::BufferIfPossible | QGeometryData::KeepClientData)
-{
- ref = 0;
- qMemSet(key, -1, ATTR_CNT);
- qMemSet(size, 0, ATTR_CNT);
-}
-
-QGeometryDataPrivate::~QGeometryDataPrivate()
-{
-}
-
-QGeometryDataPrivate *QGeometryDataPrivate::clone() const
-{
- QGeometryDataPrivate *temp = new QGeometryDataPrivate;
- temp->vertices = vertices;
- temp->normals = normals;
- temp->colors = colors;
- temp->attributes = attributes;
- temp->textures = textures;
- temp->indices = indices;
- temp->vertexBundle = vertexBundle;
- temp->indexBuffer = indexBuffer;
- temp->uploadsViable = uploadsViable;
- temp->modified = modified;
- temp->bb = bb;
- temp->fields = fields;
- qMemCopy(temp->key, key, ATTR_CNT);
- qMemCopy(temp->size, size, ATTR_CNT);
- temp->count = count;
- temp->reserved = reserved;
- temp->boxValid = boxValid;
- temp->bufferStrategy = bufferStrategy;
- return temp;
-}
-
-/*!
- \fn quint32 QGL::fieldMask(QGL::VertexAttribute attribute)
- \relates QGeometryData
- Returns an unsigned integer mask from the \a attribute.
-
- \sa QGeometryData::fields()
-*/
-
-/*!
- \enum QGeometryData::BufferStrategyFlags
-
- This enum serves to describe how management of the data is handled
- with respect to vertex buffer objects. The strategies are essentially a
- combination of whether the client data is kept around after it has been
- successfully uploaded to the GPU; and whether an upload is attempted at
- all.
-
- If the data set is very small it may be pointless to use up a VBO, hence
- in this case KeepClientData may be used resulting in no attempt to upload
- the data and client side arrays used instead.
-
- \value InvalidStrategy No valid strategy has been specified.
- \value KeepClientData Keep the client data, even after successful upload to the GPU.
- \value BufferIfPossible Try to upload the data to the GPU.
-*/
-
-/*!
- Construct an empty QGeometryData
-*/
-QGeometryData::QGeometryData()
- : d(0)
-{
-}
-
-/*!
- Construct QGeometryData as a copy of \a other
-*/
-QGeometryData::QGeometryData(const QGeometryData &other)
- : d(other.d)
-{
- if (d)
- d->ref.ref();
-}
-
-/*!
- Construct an empty QGeometryData with the \a fields enabled.
-*/
-QGeometryData::QGeometryData(quint32 fields)
- : d(new QGeometryDataPrivate)
-{
- d->ref.ref();
- const quint32 mask = 0x01;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (!(mask & fields)) continue;
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- enableField(attr);
- }
-}
-
-/*!
- Destroys this QGeometryData recovering any resources.
-*/
-QGeometryData::~QGeometryData()
-{
- if (d && !d->ref.deref())
- delete d;
-}
-
-/*!
- Assigns this QGeometryData to be a copy of \a other.
-*/
-QGeometryData &QGeometryData::operator=(const QGeometryData &other)
-{
- if (d != other.d)
- {
- if (d && !d->ref.deref())
- delete d;
- d = other.d;
- if (d)
- d->ref.ref();
- }
- return *this;
-}
-
-/*!
- Appends the geometry in \a data to this. If this is empty, then all
- fields of \a data are appended; otherwise (when this has existing fields)
- only those fields that exist in both are appended.
-
- This does not change the indices - to reference the new geometry add
- indices via the appendIndices() functions.
-*/
-void QGeometryData::appendGeometry(const QGeometryData &data)
-{
- if (data.d && data.count())
- {
- detach();
- d->modified = true;
- d->boxValid = false;
- int cnt = data.d->count;
- const quint32 mask = 0x01;
- quint32 fields = d->fields | data.fields();
- d->fields = fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- enableField(attr); // might not be enabled if we had NO fields
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- d->vertices.append(data.d->vertices);
- else if (attr == QGL::Normal)
- d->normals.append(data.d->normals);
- else // colors
- d->colors.append(data.d->colors);
- }
- else if (attr < QGL::CustomVertex0)
- {
- d->textures[d->key[attr]].append(data.texCoords(attr));
- }
- else
- {
- d->attributes[d->key[attr]].append(data.attributes(attr));
- }
- }
- }
- d->count += cnt;
- }
-}
-
-/*!
- Appends all the data fields in QLogicalVertex \a v to this
- QGeometryData object.
-*/
-int QGeometryData::appendVertex(const QLogicalVertex &v)
-{
- create();
- d->modified = true;
- if (d->boxValid)
- d->bb.unite(v.vertex());
- quint32 fields = v.fields();
- const quint32 mask = 0x01;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- appendVertex(v.vertex());
- else if (attr == QGL::Normal)
- appendNormal(v.normal());
- else
- appendColor(v.color());
- }
- else if (attr < QGL::CustomVertex0)
- {
- appendTexCoord(v.texCoord(attr), attr);
- }
- else
- {
- appendAttribute(v.attribute(attr), attr);
- }
- }
- }
- return d->count - 1;
-}
-
-/*!
- Returns a QLogicalVertex that references the \a{i}'th logical vertex
- of this geometry.
-*/
-QLogicalVertex QGeometryData::logicalVertexAt(int i) const
-{
- return QLogicalVertex(*this, i);
-}
-
-/*!
- Normalize all the normal vectors in this geometry to unit length.
-*/
-void QGeometryData::normalizeNormals()
-{
- check();
- if (d) // nothng to do if its null
- {
- create();
- d->modified = true;
- if (hasField(QGL::Normal))
- {
- for (int i = 0; i < d->normals.count(); ++i)
- d->normals[i].normalize();
- }
- }
-}
-
-/*!
- Calculate and return a bounding box for the vertex data in this geometry.
-*/
-QBox3D QGeometryData::boundingBox() const
-{
- QBox3D box;
- if (d)
- {
- if (d->boxValid)
- {
- box = d->bb;
- }
- else
- {
- for (int i = 0; i < d->count; ++i)
- box.unite(d->vertices.at(i));
- d->bb = box;
- }
- }
- return box;
-}
-
-/*!
- Returns the coordinates of the center of the geometry.
-
- The center is calculated as the centroid or geometric barycenter
- of the vertices (the average of the vertices). For a convex hull this
- is guaranteed to be inside the figure.
-*/
-QVector3D QGeometryData::center() const
-{
- QVector3D center;
- for (int i = 0; i < d->vertices.count(); ++i)
- center += d->vertices.at(i);
- return center / (float)d->vertices.count();
-}
-
-/*!
- Returns a copy of this geometry data with elements in reverse order.
-*/
-QGeometryData QGeometryData::reversed() const
-{
- QGeometryData r;
- for (int i = count() - 1; i >= 0; --i)
- r.appendVertex(logicalVertexAt(i));
- return r;
-}
-
-/*!
- Returns a copy of this geometry data with QGL::Position data translated by
- the vector \a t. The other fields are unchanged.
-*/
-QGeometryData QGeometryData::translated(const QVector3D &t) const
-{
- QGeometryData r(*this);
- r.detach();
- for (int i = 0; i < count(); ++i)
- {
- r.vertex(i) = r.vertexAt(i) + t;
- }
- return r;
-}
-
-/*!
- Modifies this geometry data by generating texture data based on QGL::Position
- values. If \a orientation is Qt::Horizontal (the default) then x-coordinate
- values are generated, and y-coordinate values are set to 0.0; otherwise
- y-coordinate values are generated and x-coordinate values are set to 0.0.
- The values are appended to the texture coordinate \a field.
-
- The method of calculation is based on the assumption that the vertex data
- is a list of extents which span across the texture space horizontally, from
- x = 0.0 to x = 1.0, in the case of Qt::Horizontal; or vertically in the
- case of Qt::Vertical. The texture space of 1.0 is divided up proportionately
- by the length of each extent.
-
- \image texture-coords-gen.png
-
- In this diagram the large blue numbers are the lengths of each extent, and
- the texture coordinates generated are shown as \c{t(7/16, 1)} and so on.
-
- Thus the texture coordinate t0 for vertex v0, is 0.0; t1 for vertex v1 is
- \c{(v1 - v0).length() / totalLength} and so on.
-
- The code to produce the texture coordinates for the quads in the image is:
- \code
- QGeometryData top;
-
- // add data to the primitive
- top.appendVertex(QVector3D(0.0, 0.0, 0.0));
- top.appendVertex(QVector3D(6.0, 3.6, 0.0)); // (v1 - v0).length() = 7.0
- top.appendVertex(QVector3D(10.0, 0.6, 0.0)); // (v2 - v1).length() = 5.0
- top.appendVertex(QVector3D(13.0, 3.24, 0.0)); // (v3 - v2).length() = 4.0
-
- // generate x (Qt::Horizontal) texture coordinates over the primitive
- top.generateTextureCoordinates(); // spread over 7 + 5 + 4 = 16
-
- // make a copy translated down, the copy has y texture coordinates all 0
- QGeometryData bottom = top.translated(QVector3D(0, 0, -1));
-
- // now modify the top so its y texture coordinates are all 1
- for (int i = 0; i < top.count(); ++i)
- top.texCoordRef(QGL::TextureCoord0).setY(1.0);
-
- displayList->addQuadsZipped(top, bottom);
- \endcode
-*/
-void QGeometryData::generateTextureCoordinates(Qt::Orientation orientation, QGL::VertexAttribute field)
-{
- QArray<qreal> extents;
- extents.append(0.0);
- qreal totalExtents = 0.0;
- QArray<QVector3D> v = vertices();
- for (int i = 0; i < v.count() - 1; ++i)
- {
- int n = (i + 1) % v.count();
- QVector3D e = v[n] - v[i];
- qreal extent = e.length();
- totalExtents += extent;
- extents.append(totalExtents);
- }
- if (hasField(field))
- clear(field);
- if (orientation == Qt::Horizontal)
- {
- for (int i = 0; i < v.count(); ++i)
- appendTexCoord(QVector2D(extents[i] / totalExtents, 0.0), field);
- }
- else
- {
- for (int i = 0; i < v.count(); ++i)
- appendTexCoord(QVector2D(0.0, extents[i] / totalExtents), field);
- }
-}
-
-/*!
- Returns a QGeometryData instance containing alternating vertices from
- this geometry and \a other. The resulting geometry contains N vertices
- where \c{N == qMin(count(), other.count())}, and has only the fields
- that are in both geometries.
-*/
-QGeometryData QGeometryData::interleavedWith(const QGeometryData &other) const
-{
- QGeometryData res;
- check();
- other.check();
- if (d && other.d)
- {
- int cnt = qMax(d->count, other.d->count);
- const quint32 mask = 0x01;
- quint32 fields = d->fields & other.d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- res.enableField(attr);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- {
- QArray<QVector3D> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->vertices.at(i));
- tmp.append(other.d->vertices.at(i));
- }
- res.d->vertices = tmp;
- }
- else if (attr == QGL::Normal)
- {
- QArray<QVector3D> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->normals.at(i));
- tmp.append(other.d->normals.at(i));
- }
- res.d->normals = tmp;
- }
- else // colors
- {
- QArray<QColor4ub> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->colors.at(i));
- tmp.append(other.d->colors.at(i));
- }
- res.d->colors = tmp;
- }
- }
- else if (attr < QGL::CustomVertex0)
- {
- QArray<QVector2D> tmp;
- const QArray<QVector2D> txa = d->textures.at(d->key[attr]);
- const QArray<QVector2D> txb = other.d->textures.at(other.d->key[attr]);
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(txa.at(i));
- tmp.append(txb.at(i));
- }
- res.d->textures[d->key[attr]] = tmp;
- }
- else
- {
- QCustomDataArray tmp;
- const QCustomDataArray ata = d->attributes.at(d->key[attr]);
- const QCustomDataArray atb = other.d->attributes.at(other.d->key[attr]);
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(ata.at(i));
- tmp.append(atb.at(i));
- }
- res.d->attributes[d->key[attr]] = tmp;
- }
- }
- }
- res.d->count = cnt * 2;
- }
- return res;
-}
-
-/*!
- Sets this QGeometryData to contain alternating vertices from
- this geometry and \a other. The resulting geometry contains \c{N * 2} vertices
- where \c{N == qMin(count(), other.count())}, and has only the fields
- that are in both geometries.
-*/
-void QGeometryData::interleaveWith(const QGeometryData &other)
-{
- check();
- other.check();
- if (d && other.d)
- {
- create();
- d->modified = true;
- d->boxValid = false;
- int cnt = qMin(d->count, other.d->count);
- const quint32 mask = 0x01;
- quint32 fields = d->fields & other.d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- {
- QArray<QVector3D> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->vertices.at(i));
- tmp.append(other.d->vertices.at(i));
- }
- d->vertices = tmp;
- }
- else if (attr == QGL::Normal)
- {
- QArray<QVector3D> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->normals.at(i));
- tmp.append(other.d->normals.at(i));
- }
- d->normals = tmp;
- }
- else // colors
- {
- QArray<QColor4ub> tmp;
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(d->colors.at(i));
- tmp.append(other.d->colors.at(i));
- }
- d->colors = tmp;
- }
- }
- else if (attr < QGL::CustomVertex0)
- {
- QArray<QVector2D> tmp;
- const QArray<QVector2D> txa = d->textures.at(d->key[attr]);
- const QArray<QVector2D> txb = other.d->textures.at(other.d->key[attr]);
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(txa.at(i));
- tmp.append(txb.at(i));
- }
- d->textures[d->key[attr]] = tmp;
- }
- else
- {
- QCustomDataArray tmp;
- const QCustomDataArray ata = d->attributes.at(d->key[attr]);
- const QCustomDataArray atb = other.d->attributes.at(other.d->key[attr]);
- for (int i = 0; i < cnt; ++i)
- {
- tmp.append(ata.at(i));
- tmp.append(atb.at(i));
- }
- d->attributes[d->key[attr]] = tmp;
- }
- }
- }
- d->count = cnt * 2;
- }
-}
-
-/*!
- Clear all data structures. The actual fields are retained, but they
- have no contents.
- \code
- QGeometryData data;
- data.appendVertex(a);
- data.appendTexCoord(t);
-
- // prints "1"
- qDebug() << data.count();
-
- // x == a
- QVector3D x = data.vertexAt(0);
-
- quint32 flds = QGL::fieldMask(QGL::Position) | QGL::fieldMask(QGL::TextureCoord0);
- qDebug() << (flds == data.fields()); // prints "true"
-
- data.clear();
- qDebug() << data.count(); // prints "0"
- QVector3D x = data.vertexAt(0); // asserts - no data in vertices
- qDebug() << (flds == data.fields()); // still prints "true"
- \endcode
-
- To clear a specific field and its data use \c{data.clear(field)} below.
-
- To clear all fields and data, simply set this to an empty geometry:
- \code
- data = QGeometryData();
- \endcode
- */
-void QGeometryData::clear()
-{
- if (d)
- {
- create();
- d->modified = true;
- d->bb = QBox3D();
- d->boxValid = true;
- const quint32 mask = 0x01;
- quint32 fields = d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- d->vertices.clear();
- else if (attr == QGL::Normal)
- d->normals.clear();
- else
- d->colors.clear();
- }
- else if (attr < QGL::CustomVertex0)
- {
- d->textures[d->key[field]].clear();
- }
- else
- {
- d->attributes[d->key[field]].clear();
- }
- }
- }
- d->count = 0;
- }
-}
-
-/*!
- Clears the data from \a field, and removes the field. After this call
- hasField() will return false for this field.
-*/
-void QGeometryData::clear(QGL::VertexAttribute field)
-{
- if (d && (QGL::fieldMask(field) & d->fields))
- {
- create();
- d->modified = true;
- if (field == QGL::Position)
- {
- d->bb = QBox3D();
- d->boxValid = true;
- }
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- d->vertices.clear();
- else if (attr == QGL::Normal)
- d->normals.clear();
- else
- d->colors.clear();
- }
- else if (attr < QGL::CustomVertex0)
- {
- d->textures[d->key[field]].clear();
- }
- else
- {
- d->attributes[d->key[field]].clear();
- }
- d->key[field] = -1;
- d->fields = d->fields & ~QGL::fieldMask(field);
- }
-}
-
-/*!
- Sets the geometry data to handle an \a amount of data. This is generally
- not required unless its anticipated that a large amount of data will be
- appended and realloc overhead is desired to be avoided. If \a amount is
- less than the amount already reserved, or if this object has
- more than the \a amount of data items, then this function exits without
- doing anything. This function will never delete data.
-*/
-void QGeometryData::reserve(int amount)
-{
- if (d && (d->reserved > amount || d->reserved < d->count))
- return;
- create();
- d->reserved = amount;
- const quint32 mask = 0x01;
- quint32 fields = d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- d->vertices.reserve(amount);
- else if (attr == QGL::Normal)
- d->normals.reserve(amount);
- else
- d->colors.reserve(amount);
- }
- else if (attr < QGL::CustomVertex0)
- {
- d->textures[d->key[field]].reserve(amount);
- }
- else
- {
- d->attributes[d->key[field]].reserve(amount);
- }
- }
- }
-}
-
-/*!
- Draws this geometry on the \a painter, from \a start for \a count elements
- in \a mode. The drawing \a mode is by default QGL::Triangles. This function
- Also calls the upload() method to ensure that the geometry is resident on
- the graphics hardware if appropriate.
-
- If the geometry is a point or line, then the \a drawWidth value specified the
- width/size of the line/point.
-*/
-void QGeometryData::draw(QGLPainter *painter, int start, int count, GLenum mode, qreal drawWidth)
-{
- if (d && d->indices.size() && d->count)
- {
- upload();
- painter->clearAttributes();
- if (mode==QGL::Points) {
-#if !defined(QT_OPENGL_ES_2)
- ::glPointSize(drawWidth);
-#endif
- } else if (mode==QGL::LineStrip || mode == QGL::Lines) {
- ::glLineWidth(drawWidth);
- }
- painter->setVertexBundle(d->vertexBundle);
- if (count == 0)
- count = d->indexBuffer.indexCount();
- painter->draw(QGL::DrawingMode(mode), d->indexBuffer, start, count);
- }
-}
-
-/*!
- Uploads this geometry data to the graphics hardware if appropriate. If the
- data is already uploaded and has not been modified since it was last
- uploaded, then this function does nothing.
-
- If the bufferStrategy() does not specify QGL::BufferIfPossible then this
- function does nothing.
-
- If the data was successfully uploaded, and the bufferStrategy() does not
- specify QGL::KeepClientData then the data will be removed with a call to
- the clear() function.
-
- If the data was successfully uploaded, on this call or previously, then this
- function will return true. Otherwise it returns false.
-*/
-bool QGeometryData::upload()
-{
- bool vboUploaded = false;
- bool iboUploaded = false;
-
- if (!d)
- return false;
- if (!d->modified)
- return d->vertexBundle.isUploaded() && d->indexBuffer.isUploaded();
-
- check();
-
- // Need to recreate the buffers from the modified data.
- d->vertexBundle = QGLVertexBundle();
- d->indexBuffer = QGLIndexBuffer();
-
- // Copy the geometry data to the vertex buffer.
- const quint32 mask = 0x01;
- quint32 fields = d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (!(mask & fields))
- continue;
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr == QGL::Position)
- d->vertexBundle.addAttribute(attr, d->vertices);
- else if (attr == QGL::Normal)
- d->vertexBundle.addAttribute(attr, d->normals);
- else if (attr == QGL::Color)
- d->vertexBundle.addAttribute(attr, d->colors);
- else if (attr < QGL::CustomVertex0)
- d->vertexBundle.addAttribute(attr, d->textures.at(d->key[field]));
- else
- d->vertexBundle.addAttribute(attr, d->attributes.at(d->key[field]));
- }
-
- // Upload the buffer if requested, otherwise keep it client-side.
- // Note: QGLVertexBundle will act as a client-side buffer if not uploaded.
- if ((d->bufferStrategy & BufferIfPossible) != 0)
- {
- if (d->vertexBundle.upload())
- vboUploaded = true;
- }
-
- // Copy the geometry data to the index buffer and upload if requested.
- d->indexBuffer.setIndexes(d->indices);
- if ((d->bufferStrategy & BufferIfPossible) != 0)
- {
- if (d->indexBuffer.upload())
- iboUploaded = true;
- }
-
- d->modified = false;
-
- if (!(d->bufferStrategy & KeepClientData) && vboUploaded && iboUploaded)
- clear();
-
- return vboUploaded && iboUploaded;
-}
-
-/*!
- Sets the buffer \a strategy for this geometry.
-
- \sa bufferStrategy()
-*/
-void QGeometryData::setBufferStrategy(QGeometryData::BufferStrategy strategy)
-{
- if (!d || d->bufferStrategy != strategy)
- {
- create();
- d->modified = true;
- d->bufferStrategy = strategy;
- }
-}
-
-/*!
- Returns the buffer strategy for this geometry. The default is
- \c{QGL::BufferIfPossible | QGL::KeepClientData}.
-
- \sa setBufferStrategy()
-*/
-QGeometryData::BufferStrategy QGeometryData::bufferStrategy() const
-{
- if (d)
- return d->bufferStrategy;
- return InvalidStrategy;
-}
-
-/*!
- Returns a reference to the vertex buffer for this geometry.
-
- \sa indexBuffer()
-*/
-QGLVertexBundle QGeometryData::vertexBundle() const
-{
- return d->vertexBundle;
-}
-
-/*!
- Returns a reference to the index buffer for this geometry.
-
- \sa vertexBundle()
-*/
-QGLIndexBuffer QGeometryData::indexBuffer() const
-{
- return d->indexBuffer;
-}
-
-/*!
- Appends \a index to the vertex index array.
-
- \sa appendIndices(), indices()
-*/
-void QGeometryData::appendIndex(int index)
-{
- create();
- d->modified = true;
- d->indices.append(index);
-}
-
-/*!
- Appends \a index1, \a index2, and \a index3 to the geometry's
- index array.
-
- \sa appendIndex(), indices()
-*/
-void QGeometryData::appendIndices(int index1, int index2, int index3)
-{
- create();
- d->modified = true;
- d->indices.append(index1, index2, index3);
-}
-
-/*!
- Returns the index array that was created by appendIndex().
-
- \sa appendIndex(), appendIndices()
-*/
-QGL::IndexArray QGeometryData::indices() const
-{
- if (d)
- return d->indices;
- else
- return QGL::IndexArray();
-}
-
-/*!
- Appends the \a indices to the geometry's index array.
-*/
-void QGeometryData::appendIndices(const QGL::IndexArray &indices)
-{
- create();
- d->modified = true;
- d->indices.append(indices);
-}
-
-/*!
- Append the point \a v0 to this geometry data as a position field.
-*/
-void QGeometryData::appendVertex(const QVector3D &v0)
-{
- create();
- d->modified = true;
- enableField(QGL::Position);
- d->vertices.append(v0);
- if (d->boxValid)
- d->bb.unite(v0);
- d->count = qMax(d->count, d->vertices.count());
-}
-
-/*!
- Append the points \a v0 and \a v1 to this geometry data as position fields.
-*/
-void QGeometryData::appendVertex(const QVector3D &v0, const QVector3D &v1)
-{
- create();
- d->modified = true;
- enableField(QGL::Position);
- d->vertices.append(v0, v1);
- if (d->boxValid)
- {
- d->bb.unite(v0);
- d->bb.unite(v1);
- }
- d->count = qMax(d->count, d->vertices.count());
-}
-
-/*!
- Append the points \a v0, \a v1 and \a v2 to this geometry data as position fields.
-*/
-void QGeometryData::appendVertex(const QVector3D &v0, const QVector3D &v1, const QVector3D &v2)
-{
- create();
- d->modified = true;
- enableField(QGL::Position);
- d->vertices.append(v0, v1, v2);
- if (d->boxValid)
- {
- d->bb.unite(v0);
- d->bb.unite(v1);
- d->bb.unite(v2);
- }
- d->count = qMax(d->count, d->vertices.count());
-}
-
-/*!
- Append the points \a v0, \a v1, \a v2 and \a v3 to this geometry data as position fields.
-*/
-void QGeometryData::appendVertex(const QVector3D &v0, const QVector3D &v1, const QVector3D &v2, const QVector3D &v3)
-{
- create();
- d->modified = true;
- enableField(QGL::Position);
- d->vertices.append(v0, v1, v2, v3);
- if (d->boxValid)
- {
- d->bb.unite(v0);
- d->bb.unite(v1);
- d->bb.unite(v2);
- d->bb.unite(v3);
- }
- d->count = qMax(d->count, d->vertices.count());
-}
-
-/*!
- Append the float \a a0 to this geometry data, as an attribute \a field.
-*/
-void QGeometryData::appendAttribute(float a0, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->attributes[d->key[field]].append(a0);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the float \a a0 and \a a1 to this geometry data, as an attribute \a field.
-*/
-void QGeometryData::appendAttribute(float a0, float a1, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->attributes[d->key[field]].append(a0, a1);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the floats \a a0, \a a1 and \a a2 to this geometry data, as attribute \a field.
-*/
-void QGeometryData::appendAttribute(float a0, float a1, float a2, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->attributes[d->key[field]].append(a0, a1, a2);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the floats \a a0, \a a1, \a a2 and \a a3 to this geometry data, as attribute \a field.
-*/
-void QGeometryData::appendAttribute(float a0, float a1, float a2, float a3, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->attributes[d->key[field]].append(a0, a1, a2, a3);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the 2D point \a a to this geometry data, as an attribute \a field.
-*/
-void QGeometryData::appendAttribute(const QVector2D &a, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- if (d->attributes.at(d->key[field]).isEmpty())
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Vector2D);
- d->attributes[d->key[field]].append(a);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the 3D point \a v to this geometry data, as an attribute \a field.
-*/
-void QGeometryData::appendAttribute(const QVector3D &v, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- if (d->attributes.at(d->key[field]).isEmpty())
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Vector3D);
- d->attributes[d->key[field]].append(v);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the variant value \a a to this geometry data, as an attribute \a field.
-*/
-void QGeometryData::appendAttribute(const QVariant &a, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- if (d->attributes.at(d->key[field]).isEmpty())
- {
- // floats and doubles get handled "automatically" - float is default
- if (a.type() == QVariant::Vector2D)
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Vector2D);
- else if (a.type() == QVariant::Vector3D)
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Vector3D);
- else if (a.type() == QVariant::Vector4D)
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Vector4D);
- else if (a.type() == QVariant::Color)
- d->attributes[d->key[field]].setElementType(QCustomDataArray::Color);
- else
- Q_ASSERT_X(false, "QGeometryData::appendAttribute", "bad type");
- }
- d->attributes[d->key[field]].append(a);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
-}
-
-/*!
- Append the vector \a n0 to this geometry data, as a lighting normal.
-*/
-void QGeometryData::appendNormal(const QVector3D &n0)
-{
- create();
- d->modified = true;
- enableField(QGL::Normal);
- d->normals.append(n0);
- d->count = qMax(d->count, d->normals.count());
-}
-
-/*!
- Append the vectors \a n0 and \a n1 to this geometry data, as lighting normals.
-*/
-void QGeometryData::appendNormal(const QVector3D &n0, const QVector3D &n1)
-{
- create();
- d->modified = true;
- enableField(QGL::Normal);
- d->normals.append(n0, n1);
- d->count = qMax(d->count, d->normals.count());
-}
-
-/*!
- Append the vectors \a n0, \a n1 and \a n2 to this geometry data, as lighting normals.
-*/
-void QGeometryData::appendNormal(const QVector3D &n0, const QVector3D &n1, const QVector3D &n2)
-{
- create();
- d->modified = true;
- enableField(QGL::Normal);
- d->normals.append(n0, n1, n2);
- d->count = qMax(d->count, d->normals.count());
-}
-
-/*!
- Append the vectors \a n0, \a n1, \a n2 and \a n3 to this geometry data, as lighting normals.
-*/
-void QGeometryData::appendNormal(const QVector3D &n0, const QVector3D &n1, const QVector3D &n2, const QVector3D &n3)
-{
- create();
- d->modified = true;
- enableField(QGL::Normal);
- d->normals.append(n0, n1, n2, n3);
- d->count = qMax(d->count, d->normals.count());
-}
-
-/*!
- Append the point \a t0 to this geometry data, as an texture \a field.
-*/
-void QGeometryData::appendTexCoord(const QVector2D &t0, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->textures[d->key[field]].append(t0);
- d->count = qMax(d->count, d->textures[d->key[field]].count());
-}
-
-/*!
- Append the points \a t0 and \a t1 to this geometry data, as texture \a{field}s.
-*/
-void QGeometryData::appendTexCoord(const QVector2D &t0, const QVector2D &t1, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->textures[d->key[field]].append(t0, t1);
- d->count = qMax(d->count, d->textures[d->key[field]].count());
-}
-
-/*!
- Append the points \a t0, \a t1 and \a t2 to this geometry data, as texture \a{field}s.
-*/
-void QGeometryData::appendTexCoord(const QVector2D &t0, const QVector2D &t1, const QVector2D &t2, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->textures[d->key[field]].append(t0, t1, t2);
- d->count = qMax(d->count, d->textures[d->key[field]].count());
-}
-
-/*!
- Append the points \a t0, \a t1, \a t2 and \a t3 to this geometry data, as texture \a{field}s.
-*/
-void QGeometryData::appendTexCoord(const QVector2D &t0, const QVector2D &t1, const QVector2D &t2, const QVector2D &t3, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- enableField(field);
- d->textures[d->key[field]].append(t0, t1, t2, t3);
- d->count = qMax(d->count, d->textures[d->key[field]].count());
-}
-
-/*!
- Append the color \a c0 to this geometry data, as an color field.
-*/
-void QGeometryData::appendColor(const QColor4ub &c0)
-{
- create();
- d->modified = true;
- enableField(QGL::Color);
- d->colors.append(c0);
- d->count = qMax(d->count, d->colors.count());
-}
-
-/*!
- Append the color \a c0 and \a c1 to this geometry data, as color fields.
-*/
-void QGeometryData::appendColor(const QColor4ub &c0, const QColor4ub &c1)
-{
- create();
- d->modified = true;
- enableField(QGL::Color);
- d->colors.append(c0, c1);
- d->count = qMax(d->count, d->colors.count());
-}
-
-/*!
- Append the color \a c0, \a c1 and \a c2 to this geometry data, as color fields.
-*/
-void QGeometryData::appendColor(const QColor4ub &c0, const QColor4ub &c1, const QColor4ub &c2)
-{
- create();
- d->modified = true;
- enableField(QGL::Color);
- d->colors.append(c0, c1, c2);
- d->count = qMax(d->count, d->colors.count());
-}
-
-/*!
- Append the color \a c0, \a c1, \a c2 and \a c3 to this geometry data, as color fields.
-*/
-void QGeometryData::appendColor(const QColor4ub &c0, const QColor4ub &c1, const QColor4ub &c2, const QColor4ub &c3)
-{
- create();
- d->modified = true;
- enableField(QGL::Color);
- d->colors.append(c0, c1, c2, c3);
- d->count = qMax(d->count, d->colors.count());
-}
-
-/*!
- Append the points in \a ary to this geometry data as position fields.
-*/
-void QGeometryData::appendVertexArray(const QVector3DArray &ary)
-{
- if (ary.count())
- {
- create();
- d->modified = true;
- d->boxValid = false;
- enableField(QGL::Position);
- d->vertices.append(ary);
- d->count = qMax(d->count, d->vertices.count());
- }
-}
-
-/*!
- Append the points in \a ary to this geometry data, as an attribute \a field entries.
-*/
-void QGeometryData::appendAttributeArray(const QCustomDataArray &ary, QGL::VertexAttribute field)
-{
- if (ary.count())
- {
- create();
- d->modified = true;
- enableField(field);
- d->attributes[d->key[field]].append(ary);
- d->count = qMax(d->count, d->attributes[d->key[field]].count());
- }
-}
-
-/*!
- Append the vectors in \a ary to this geometry data, as lighting normals.
-*/
-void QGeometryData::appendNormalArray(const QVector3DArray &ary)
-{
- if (ary.count())
- {
- create();
- d->modified = true;
- enableField(QGL::Normal);
- d->normals.append(ary);
- d->count = qMax(d->count, d->normals.count());
- }
-}
-
-/*!
- Append the 2D points in \a ary to this geometry data, as texture \a field entries.
-*/
-void QGeometryData::appendTexCoordArray(const QVector2DArray &ary, QGL::VertexAttribute field)
-{
- if (ary.count())
- {
- create();
- d->modified = true;
- enableField(field);
- d->textures[d->key[field]].append(ary);
- d->count = qMax(d->count, d->textures[d->key[field]].count());
- }
-}
-
-/*!
- Append the colors in \a ary to this geometry data, as color fields.
-*/
-void QGeometryData::appendColorArray(const QArray<QColor4ub> &ary)
-{
- if (ary.count())
- {
- create();
- d->modified = true;
- enableField(QGL::Color);
- d->colors.append(ary);
- d->count = qMax(d->count, d->colors.count());
- }
-}
-
-/*!
- Returns a modifiable reference to the vertex data at index \a i.
-*/
-QVector3D &QGeometryData::vertex(int i)
-{
- create();
- d->modified = true;
- d->boxValid = false;
- return d->vertices[i];
-}
-
-/*!
- Returns a copy of the vertex position data.
-*/
-QVector3DArray QGeometryData::vertices() const
-{
- if (d)
- return d->vertices;
- return QArray<QVector3D>();
-}
-
-/*!
- \internal
- Returns a pointer to the vertex data.
-*/
-const QVector3DArray *QGeometryData::vertexData() const
-{
- if (d)
- return &d->vertices;
- return 0;
-}
-
-
-/*!
- Returns a non-modifiable reference to the vertex position data at index \a i.
-*/
-const QVector3D &QGeometryData::vertexAt(int i) const
-{
- Q_ASSERT(hasField(QGL::Position));
- return d->vertices.at(i);
-}
-
-/*!
- Returns a modifiable reference to the normal data at index \a i.
-*/
-QVector3D &QGeometryData::normal(int i)
-{
- create();
- d->modified = true;
- return d->normals[i];
-}
-
-/*!
- Returns a non-modifiable reference to the normal data at index \a i.
-*/
-const QVector3D &QGeometryData::normalAt(int i) const
-{
- Q_ASSERT(hasField(QGL::Normal));
- return d->normals.at(i);
-}
-
-/*!
- Returns a copy of the lighting normal data.
-*/
-QVector3DArray QGeometryData::normals() const
-{
- if (d)
- return d->normals;
- return QArray<QVector3D>();
-}
-
-/*!
- Returns a modifiable reference to the color data at index \a i.
-*/
-QColor4ub &QGeometryData::color(int i)
-{
- create();
- d->modified = true;
- return d->colors[i];
-}
-
-/*!
- Returns a non-modifiable reference to the color data at index \a i.
-*/
-const QColor4ub &QGeometryData::colorAt(int i) const
-{
- Q_ASSERT(hasField(QGL::Color));
- return d->colors.at(i);
-}
-
-/*!
- Returns a copy of the color data.
-*/
-QArray<QColor4ub> QGeometryData::colors() const
-{
- if (d)
- return d->colors;
- return QArray<QColor4ub>();
-}
-
-/*!
- Returns a modifiable reference to the \a field texture coordinate data at index \a i.
-*/
-QVector2D &QGeometryData::texCoord(int i, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- return d->textures[d->key[field]][i];
-}
-
-/*!
- Returns a copy of the \a field texture coordinate data.
-*/
-QVector2DArray QGeometryData::texCoords(QGL::VertexAttribute field) const
-{
- return hasField(field) ? d->textures.at(d->key[field]) : QVector2DArray();
-}
-
-/*!
- Returns a non-modifiable reference to the texture coordinate data at index \a i for \a field.
-*/
-const QVector2D &QGeometryData::texCoordAt(int i, QGL::VertexAttribute field) const
-{
- Q_ASSERT(hasField(field));
- return d->textures.at(d->key[field]).at(i);
-}
-
-/*!
- Returns a modifiable reference to the float \a field attribute data at index \a i.
-*/
-float &QGeometryData::floatAttribute(int i, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- QCustomDataArray &ary = d->attributes[d->key[field]];
- Q_ASSERT(ary.elementType() == QCustomDataArray::Float);
- return ary.m_array[i];
-}
-
-/*!
- Returns a modifiable reference to the 2D vector \a field attribute data at index \a i.
-*/
-QVector2D &QGeometryData::vector2DAttribute(int i, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- QCustomDataArray &ary = d->attributes[d->key[field]];
- Q_ASSERT(ary.elementType() == QCustomDataArray::Vector2D);
- float *data = ary.m_array.data();
- QVector2D *v = reinterpret_cast<QVector2D*>(data + i*2);
- return *v;
-}
-
-/*!
- Returns a modifiable reference to the 3D vector \a field attribute data at index \a i.
-*/
-QVector3D &QGeometryData::vector3DAttribute(int i, QGL::VertexAttribute field)
-{
- create();
- d->modified = true;
- QCustomDataArray &ary = d->attributes[d->key[field]];
- Q_ASSERT(ary.elementType() == QCustomDataArray::Vector3D);
- float *data = ary.m_array.data();
- QVector3D *v = reinterpret_cast<QVector3D*>(data + i*2);
- return *v;
-}
-
-/*!
- Returns a copy of the \a field attribute data.
-*/
-QCustomDataArray QGeometryData::attributes(QGL::VertexAttribute field) const
-{
- return hasField(field) ? d->attributes.at(d->key[field]) : QCustomDataArray();
-}
-
-/*!
- Returns a copy of the float \a field attribute data at index \a i.
-*/
-float QGeometryData::floatAttributeAt(int i, QGL::VertexAttribute field) const
-{
- Q_ASSERT(hasField(field));
- return d->attributes.at(d->key[field]).floatAt(i);
-}
-
-/*!
- Returns a copy of the 2D vector \a field attribute data at index \a i.
-*/
-QVector2D QGeometryData::vector2DAttributeAt(int i, QGL::VertexAttribute field) const
-{
- Q_ASSERT(hasField(field));
- return d->attributes.at(d->key[field]).vector2DAt(i);
-}
-
-/*!
- Returns a copy of the 3D vector \a field attribute data at index \a i.
-*/
-QVector3D QGeometryData::vector3DAttributeAt(int i, QGL::VertexAttribute field) const
-{
- Q_ASSERT(hasField(field));
- return d->attributes.at(d->key[field]).vector3DAt(i);
-}
-
-/*!
- Returns the attribute value for the \a field, suitable for passing
- to QGLPainter.
-
- \sa QGLPainter::setVertexAttribute()
-*/
-QGLAttributeValue QGeometryData::attributeValue(QGL::VertexAttribute field) const
-{
- if (hasField(field))
- {
- if (field < QGL::TextureCoord0)
- {
- if (field == QGL::Position)
- return QGLAttributeValue(d->vertices);
- else if (field == QGL::Normal)
- return QGLAttributeValue(d->normals);
- else if (field == QGL::Color)
- return QGLAttributeValue(d->colors);
- }
- else
- {
- if (field < QGL::CustomVertex0)
- return QGLAttributeValue(d->textures.at(d->key[field]));
- else
- return QGLAttributeValue(d->attributes.at(d->key[field]));
- }
- }
- return QGLAttributeValue();
-}
-
-/*!
- Returns true if this geometry has the field corresponding to \a attr. Note
- that it is still possible for no data to have been added for that field.
-*/
-bool QGeometryData::hasField(QGL::VertexAttribute attr) const
-{
- if (d)
- return d->key[attr] != -1;
- return false;
-}
-
-/*!
- Enables this geometry to contain data of type \a field. Generally it is
- not necessary to call this function since it is called by all the append
- functions.
-*/
-void QGeometryData::enableField(QGL::VertexAttribute field)
-{
- if (d && d->key[field] != -1)
- return;
- create();
- d->modified = true;
- Q_ASSERT(field < d->ATTR_CNT); // don't expand that enum too much
- d->fields |= (1 << field);
- switch (field)
- {
- case QGL::Position:
- d->key[QGL::Position] = 0;
- d->size[QGL::Position] = 3;
- if (d->reserved > 0)
- d->vertices.reserve(d->reserved);
- break;
- case QGL::Normal:
- d->key[QGL::Normal] = 1;
- d->size[QGL::Normal] = 3;
- if (d->reserved > 0)
- d->normals.reserve(d->reserved);
- break;
- case QGL::Color:
- d->key[QGL::Color] = 2;
- d->size[QGL::Color] = 1;
- if (d->reserved > 0)
- d->colors.reserve(d->reserved);
- break;
- case QGL::TextureCoord0:
- case QGL::TextureCoord1:
- case QGL::TextureCoord2:
- d->textures.append(QVector2DArray());
- d->key[field] = d->textures.count() - 1;
- d->size[field] = 2;
- if (d->reserved > 0)
- d->textures[d->key[field]].reserve(d->reserved);
- break;
- default:
- // Custom and User vertex attributes.
- d->attributes.append(QCustomDataArray());
- d->key[field] = d->attributes.count() - 1;
- d->size[field] = d->attributes.at(d->key[field]).elementSize();
- if (d->reserved > 0)
- d->attributes[d->key[field]].reserve(d->reserved);
- break;
- }
-}
-
-/*!
- Return a bit-mask of the supported fields in this geometry. The
- QGL::VertexAttribute enum can be recovered from this bit-mask by
- \code
- quint32 fields = fields();
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(fields);
- \endcode
-*/
-quint32 QGeometryData::fields() const
-{
- if (d)
- return d->fields;
- return 0;
-}
-
-/*!
- Returns the count of logical vertices stored. This is effectively
- the max() of QArray::count() over all of the enabled data types.
-*/
-int QGeometryData::count() const
-{
- if (d)
- return d->count;
- return 0;
-}
-
-/*!
- Returns the count of data stored in \a field. This will always be at
- most count(), but could be less.
-*/
-int QGeometryData::count(QGL::VertexAttribute field) const
-{
- int result = 0;
- if (d && (QGL::fieldMask(field) & d->fields))
- {
- if (field < QGL::TextureCoord0)
- {
- if (field == QGL::Position)
- result = d->vertices.count();
- else if (field == QGL::Normal)
- result = d->normals.count();
- else
- result = d->colors.count();
- }
- else if (field < QGL::CustomVertex0)
- {
- result = d->textures[d->key[field]].count();
- }
- else
- {
- result = d->attributes[d->key[field]].count();
- }
- }
- return result;
-}
-
-/*!
- Returns true if this geometry is identical to the \a other; and false otherwise.
-*/
-bool QGeometryData::operator==(const QGeometryData &other) const
-{
- bool isEqual = false;
- if (d)
- {
- if (d == other.d)
- {
- isEqual = true;
- }
- else
- {
- if (other.d && d->fields == other.d->fields && d->count == other.d->count)
- {
- const quint32 mask = 0x01;
- quint32 fields = d->fields;
- isEqual = true;
- for (int field = 0; fields && isEqual; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- isEqual = (d->vertices == other.d->vertices);
- else if (attr == QGL::Normal)
- isEqual = (d->normals == other.d->normals);
- else // colors
- isEqual = (d->colors == other.d->colors);
- }
- else if (attr < QGL::CustomVertex0)
- {
- isEqual = (d->textures.at(d->key[attr]) == other.d->textures.at(d->key[attr]));
- }
- else
- {
- QArray<float> me = d->attributes.at(d->key[attr]).toFloatArray();
- QArray<float> him = other.d->attributes.at(d->key[attr]).toFloatArray();
- isEqual = (me == him);
- }
- }
- }
- }
- }
- }
- else
- {
- isEqual = other.isNull();
- }
- return isEqual;
-}
-
-/*!
- Returns true if this geometry is empty - that is it contains no vertices
- or other data - and returns false otherwise. If an existing geometry has
- been made empty by a call to clear() then this will be true (but isNull()
- will be false).
-
- \sa isNull()
-*/
-bool QGeometryData::isEmpty() const
-{
- bool empty = true;
- if (d)
- empty = d->count == 0;
- return empty;
-}
-
-/*!
- Returns true if this geometry is uninitialized - that is it contains no
- internal data structures. A newly constructed QGeometryData object is
- null until some data is added or changed.
-
- \sa isEmpty()
-*/
-bool QGeometryData::isNull() const
-{
- return d == NULL;
-}
-
-/*!
- Returns the number of index values stored in this geometry data.
-
- This value is exactly the same as indices().size() (but does not
- incur the copy).
-*/
-int QGeometryData::indexCount() const
-{
- if (d)
- return d->indices.size();
- return 0;
-}
-
-void QGeometryData::create()
-{
- if (!d) // lazy creation of data block
- {
- d = new QGeometryDataPrivate;
- d->ref.ref();
- }
-}
-
-/*!
- Force this geometry to ensure it has its own unshared internal data
- block, making a copy in the case that it is currently shared.
-*/
-void QGeometryData::detach()
-{
- create();
- if (d->ref > 1) // being shared, must detach
- {
- QGeometryDataPrivate *temp = d->clone();
- d->ref.deref();
- d = temp;
- d->ref.ref();
- }
-}
-
-/*!
- \fn quint64 QGeometryData::id() const
- Return an opaque value that can be used to identify which data block is
- being used by this QGeometryData instance. See the class documentation
- relating to explicit sharing.
-*/
-
-#ifndef QT_NO_DEBUG
-void QGeometryData::check() const
-{
- if (!d)
- return;
- const quint32 mask = 0x01;
- quint32 fields = d->fields;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- {
- if (d->vertices.count() < d->count)
- qWarning("QGeometryData - expected %d vertices, only %d found!",
- d->count, d->vertices.count());
- }
- else if (attr == QGL::Normal)
- {
- if (d->normals.count() < d->count)
- qWarning("QGeometryData - expected %d normals, only %d found!",
- d->count, d->normals.count());
- }
- else
- {
- if (d->colors.count() < d->count)
- qWarning("QGeometryData - expected %d colors, only %d found!",
- d->count, d->colors.count());
- }
- }
- else if (attr < QGL::CustomVertex0)
- {
- if (d->textures.at(d->key[field]).count() < d->count)
- qWarning("QGeometryData - expected %d texture coordinates for"
- "QGL::TextureCoord%d, only %d found!",
- d->count, field - QGL::TextureCoord0, d->textures.at(d->key[field]).count());
- }
- else
- {
- if (d->attributes.at(d->key[field]).count() < d->count)
- qWarning("QGeometryData - expected %d attributes for"
- "QGL::CustomVertex%d, only %d found!",
- d->count, field - QGL::CustomVertex0, d->attributes.at(d->key[field]).count());
- }
- }
- }
-}
-#endif
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QGeometryData &vertices)
-{
- dbg << "QGeometryData" << &vertices << " size:" << vertices.count()
-#ifndef QT_NO_DEBUG
- << "data block id:" << vertices.id()
-#endif
- ;
- quint32 fields = vertices.fields();
- const quint32 mask = 0x01;
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- {
- dbg << " vertices:" << vertices.count(attr);
- dbg << vertices.vertices();
- }
- else if (attr == QGL::Normal)
- {
- dbg << " normals:" << vertices.count(attr);
- dbg << vertices.normals();
- }
- else
- {
- dbg << " colors:" << vertices.count(attr);
- dbg << vertices.colors();
- }
- }
- else if (attr < QGL::CustomVertex0)
- {
- dbg << " textures:" << (attr - QGL::TextureCoord0) << vertices.count(attr);
- dbg << vertices.texCoords(attr);
- }
- else
- {
- dbg << " custom:" << (attr - QGL::CustomVertex0) << vertices.count(attr);
- dbg << vertices.texCoords(attr);
- }
- }
- }
- if (vertices.indexCount() > 0)
- {
- dbg << " indices:" << vertices.indices();
- }
- return dbg;
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/geometry/qgeometrydata.h b/src/threed/geometry/qgeometrydata.h
deleted file mode 100644
index bab4588e..00000000
--- a/src/threed/geometry/qgeometrydata.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGEOMETRYDATA_H
-#define QGEOMETRYDATA_H
-
-#include "qcolor4ub.h"
-#include "qglnamespace.h"
-#include "qglindexbuffer.h"
-#include "qglvertexbundle.h"
-#include "qglattributevalue.h"
-#include "qcustomdataarray.h"
-#include "qbox3d.h"
-#include "qarray.h"
-#include "qvector2darray.h"
-#include "qvector3darray.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeometryDataPrivate;
-class QLogicalVertex;
-class QGLPainter;
-
-namespace QGL
-{
- inline quint32 fieldMask(QGL::VertexAttribute f) { return (quint32)0x01 << f; }
-
-#if defined(QT_OPENGL_ES)
- typedef QArray<ushort> IndexArray;
-#else
- typedef QArray<uint> IndexArray;
-#endif
-};
-
-class Q_QT3D_EXPORT QGeometryData
-{
-public:
- QGeometryData();
- QGeometryData(const QGeometryData &);
- QGeometryData(quint32 fields);
- ~QGeometryData();
-
- QGeometryData &operator=(const QGeometryData &);
-
- void appendGeometry(const QGeometryData &data);
- int appendVertex(const QLogicalVertex &v);
- void normalizeNormals();
- QBox3D boundingBox() const;
- QVector3D center() const;
-
- QGeometryData reversed() const;
- QGeometryData translated(const QVector3D &) const;
- void generateTextureCoordinates(Qt::Orientation orientation = Qt::Horizontal,
- QGL::VertexAttribute attribute = QGL::TextureCoord0);
- QGeometryData interleavedWith(const QGeometryData &other) const;
- void interleaveWith(const QGeometryData &other);
- void clear();
- void clear(QGL::VertexAttribute);
- void reserve(int amount);
- void draw(QGLPainter *painter, int start, int count, GLenum mode = QGL::Triangles, qreal drawWidth=1.0);
- bool upload();
- enum BufferStrategyFlags
- {
- InvalidStrategy = 0x00,
- KeepClientData = 0x01,
- BufferIfPossible = 0x02,
- };
- Q_DECLARE_FLAGS(BufferStrategy, BufferStrategyFlags)
- void setBufferStrategy(BufferStrategy strategy);
- BufferStrategy bufferStrategy() const;
- QGLVertexBundle vertexBundle() const;
- QGLIndexBuffer indexBuffer() const;
-
- void appendIndex(int index);
- void appendIndices(int index1, int index2, int index3);
- void appendIndices(const QGL::IndexArray &indices);
- QGL::IndexArray indices() const;
-
- void appendVertex(const QVector3D &v0);
- void appendVertex(const QVector3D &v0, const QVector3D &v1);
- void appendVertex(const QVector3D &v0, const QVector3D &v1, const QVector3D &v2);
- void appendVertex(const QVector3D &v0, const QVector3D &v1, const QVector3D &v2, const QVector3D &v3);
-
- void appendAttribute(float a, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(float a, float b, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(float a, float b, float c, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(float a, float b, float c, float d, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(const QVector2D &a, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(const QVector3D &a, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendAttribute(const QVariant &a, QGL::VertexAttribute field = QGL::CustomVertex0);
-
- void appendNormal(const QVector3D &n0);
- void appendNormal(const QVector3D &n0, const QVector3D &n1);
- void appendNormal(const QVector3D &n0, const QVector3D &n1, const QVector3D &n2);
- void appendNormal(const QVector3D &n0, const QVector3D &n1, const QVector3D &n2, const QVector3D &n3);
-
- void appendTexCoord(const QVector2D &t0, QGL::VertexAttribute field = QGL::TextureCoord0);
- void appendTexCoord(const QVector2D &t0, const QVector2D &t1, QGL::VertexAttribute field = QGL::TextureCoord0);
- void appendTexCoord(const QVector2D &t0, const QVector2D &t1, const QVector2D &t2, QGL::VertexAttribute field = QGL::TextureCoord0);
- void appendTexCoord(const QVector2D &t0, const QVector2D &t1, const QVector2D &t2, const QVector2D &t3, QGL::VertexAttribute field = QGL::TextureCoord0);
-
- void appendColor(const QColor4ub &c0);
- void appendColor(const QColor4ub &c0, const QColor4ub &c1);
- void appendColor(const QColor4ub &c0, const QColor4ub &c1, const QColor4ub &c2);
- void appendColor(const QColor4ub &c0, const QColor4ub &c1, const QColor4ub &c2, const QColor4ub &c3);
-
- void appendVertexArray(const QVector3DArray &ary);
- void appendAttributeArray(const QCustomDataArray &ary, QGL::VertexAttribute field = QGL::CustomVertex0);
- void appendNormalArray(const QVector3DArray &ary);
- void appendTexCoordArray(const QVector2DArray &ary, QGL::VertexAttribute field = QGL::TextureCoord0);
- void appendColorArray(const QArray<QColor4ub> &ary);
-
- QLogicalVertex logicalVertexAt(int i) const;
-
- QVector3DArray vertices() const;
- QVector3D &vertex(int i);
- const QVector3D &vertexAt(int i) const;
-
- QVector3DArray normals() const;
- QVector3D &normal(int i);
- const QVector3D &normalAt(int i) const;
-
- QArray<QColor4ub> colors() const;
- QColor4ub &color(int i);
- const QColor4ub &colorAt(int i) const;
-
- QVector2DArray texCoords(QGL::VertexAttribute field = QGL::TextureCoord0) const;
- QVector2D &texCoord(int i, QGL::VertexAttribute field = QGL::TextureCoord0);
- const QVector2D &texCoordAt(int i, QGL::VertexAttribute field = QGL::TextureCoord0) const;
-
- float &floatAttribute(int i, QGL::VertexAttribute field = QGL::CustomVertex0);
- QVector2D &vector2DAttribute(int i, QGL::VertexAttribute field = QGL::CustomVertex0);
- QVector3D &vector3DAttribute(int i, QGL::VertexAttribute field = QGL::CustomVertex0);
- QCustomDataArray attributes(QGL::VertexAttribute field = QGL::CustomVertex0) const;
- float floatAttributeAt(int i, QGL::VertexAttribute field = QGL::CustomVertex0) const;
- QVector2D vector2DAttributeAt(int i, QGL::VertexAttribute field = QGL::CustomVertex0) const;
- QVector3D vector3DAttributeAt(int i, QGL::VertexAttribute field = QGL::CustomVertex0) const;
-
- QGLAttributeValue attributeValue(QGL::VertexAttribute field) const;
- bool hasField(QGL::VertexAttribute field) const;
- void enableField(QGL::VertexAttribute field);
- quint32 fields() const;
- int count() const;
- int count(QGL::VertexAttribute field) const;
- int indexCount() const;
- bool operator==(const QGeometryData &other) const;
- bool isEmpty() const;
- bool isNull() const;
- void detach();
-#ifndef QT_NO_DEBUG
- quint64 id() const { return (quint64)d; }
-#endif
-protected:
- const QVector3DArray *vertexData() const;
-private:
- void create();
-#ifndef QT_NO_DEBUG
- void check() const;
-#else
- void check() const {}
-#endif
- friend class QLogicalVertex;
-
- QGeometryDataPrivate *d;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGeometryData::BufferStrategy);
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGeometryData &vertices);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QGEOMETRYDATA_H
diff --git a/src/threed/geometry/qglbezierpatches.cpp b/src/threed/geometry/qglbezierpatches.cpp
deleted file mode 100644
index 6d97bc88..00000000
--- a/src/threed/geometry/qglbezierpatches.cpp
+++ /dev/null
@@ -1,815 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglbezierpatches.h"
-#include "qglbuilder.h"
-#include "qray3d.h"
-#include "qtriangle3d.h"
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLBezierPatches
- \brief The QGLBezierPatches class represents 3D geometry as a set of Bezier bicubic patches.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- Bezier bicubic patches represent a curved 3D surface by four fixed
- control points at indices 0, 3, 12, and 15, together with twelve
- additional floating control points that define the surface
- curvature. Bezier geometry objects are made up of one or more
- such patches to define the surface of an object.
-
- The application specifies the vertex position data to the
- constructor, and can optionally provide an index array.
- The class interprets groups of 16 vertices as the control
- points for successive patches.
-
- A mesh defined by QGLBezierPatches is subdivided into flat
- triangles for rendering when the \c{<<} operator is used
- to add the patches to a QGLBuilder.
-
- Many curved 3D objects can be defined as being made up of Bezier
- bicubic patches, stitched together into a mesh. The most famous
- Bezier bicubic object is probably the classic 3D "Utah Teapot",
- first rendered in 1975. The QGLTeapot class provides a built-in
- implementation of this object for testing purposes.
-
- If texture co-ordinates are supplied via setTextureCoords(),
- then patch texture co-ordinates will be derived from the
- specified values as the patches are subdivided. Otherwise,
- QGLBezierPatches will generate texture co-ordinates for each
- patch based on the default square from (0, 0) to (1, 1).
- The first vertex in the patch corresponds to (0, 0),
- and the opposite vertex in the patch corresponds to (1, 1).
-
- \sa QGLBuilder, QGLTeapot
-*/
-
-class QGLBezierPatchesPrivate
-{
-public:
- QGLBezierPatchesPrivate()
- : subdivisionDepth(4) {}
- QGLBezierPatchesPrivate(const QGLBezierPatchesPrivate *other)
- : positions(other->positions)
- , textureCoords(other->textureCoords)
- , subdivisionDepth(other->subdivisionDepth) {}
-
- void copy(const QGLBezierPatchesPrivate *other)
- {
- positions = other->positions;
- textureCoords = other->textureCoords;
- subdivisionDepth = other->subdivisionDepth;
- }
-
- void subdivide(QGLBuilder *list) const;
- qreal intersection
- (const QRay3D &ray, bool anyIntersection, QVector2D *texCoord, int *patch) const;
-
- QVector3DArray positions;
- QVector2DArray textureCoords;
- int subdivisionDepth;
-};
-
-// Temporary patch data for performing sub-divisions.
-class QGLBezierPatch
-{
-public:
- // Control points for this mesh.
- QVector3D points[16];
-
- // Triangle mesh indices of the control points at each corner.
- int indices[4];
-
- QVector3D normal(qreal s, qreal t) const;
- void convertToTriangles
- (QGeometryData *prim,
- qreal xtex, qreal ytex, qreal wtex, qreal htex);
- void subDivide(QGLBezierPatch &patch1, QGLBezierPatch &patch2,
- QGLBezierPatch &patch3, QGLBezierPatch &patch4);
- void createNewCorners(QGLBezierPatch &patch1, QGLBezierPatch &patch2,
- QGLBezierPatch &patch3, QGLBezierPatch &patch4,
- QGeometryData *prim,
- qreal xtex, qreal ytex, qreal wtex, qreal htex);
- void recursiveSubDivide
- (QGeometryData *prim,
- int depth, qreal xtex, qreal ytex, qreal wtex, qreal htex);
- qreal intersection
- (qreal result, int depth, const QRay3D &ray, bool anyIntersection,
- qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc);
-};
-
-static int const cornerOffsets[] = {0, 3, 12, 15};
-static qreal const cornerS[] = {0.0f, 1.0f, 0.0f, 1.0f};
-static qreal const cornerT[] = {0.0f, 0.0f, 1.0f, 1.0f};
-
-// Helper functions for calculating the components of the Bernstein
-// polynomial and its derivative that make up the surface.
-static inline qreal b0(qreal v)
-{
- return (1.0f - v) * (1.0f - v) * (1.0f - v);
-}
-static inline qreal b1(qreal v)
-{
- return 3.0f * v * (1.0f - v) * (1.0f - v);
-}
-static inline qreal b2(qreal v)
-{
- return 2.0f * v * v * (1.0f - v);
-}
-static inline qreal b3(qreal v)
-{
- return v * v * v;
-}
-static inline qreal db0(qreal v)
-{
- return -3.0f * (1.0f - v) * (1.0f - v);
-}
-static inline qreal db1(qreal v)
-{
- return -6.0f * v * (1.0f - v) + 3.0f * (1.0f - v) * (1.0f - v);
-}
-static inline qreal db2(qreal v)
-{
- return -3.0f * v * v + 6.0f * v * (1.0f - v);
-}
-static inline qreal db3(qreal v)
-{
- return 3.0f * v * v;
-}
-
-// Compute the normal at a specific point in the patch.
-// The s and t values vary between 0 and 1.
-QVector3D QGLBezierPatch::normal(qreal s, qreal t) const
-{
- qreal a[4];
- qreal b[4];
- qreal tx, ty, tz;
- qreal sx, sy, sz;
-
- // Compute the derivative of the surface in t.
- a[0] = b0(s);
- a[1] = b1(s);
- a[2] = b2(s);
- a[3] = b3(s);
- b[0] = db0(t);
- b[1] = db1(t);
- b[2] = db2(t);
- b[3] = db3(t);
- tx = 0.0f;
- ty = 0.0f;
- tz = 0.0f;
- for (int i = 0; i < 4; ++i) {
- for (int j = 0; j < 4; ++j) {
- tx += a[i] * points[j * 4 + i].x() * b[j];
- ty += a[i] * points[j * 4 + i].y() * b[j];
- tz += a[i] * points[j * 4 + i].z() * b[j];
- }
- }
-
- // Compute the derivative of the surface in s.
- a[0] = db0(s);
- a[1] = db1(s);
- a[2] = db2(s);
- a[3] = db3(s);
- b[0] = b0(t);
- b[1] = b1(t);
- b[2] = b2(t);
- b[3] = b3(t);
- sx = 0.0f;
- sy = 0.0f;
- sz = 0.0f;
- for (int i = 0; i < 4; ++i) {
- for (int j = 0; j < 4; ++j) {
- sx += a[i] * points[j * 4 + i].x() * b[j];
- sy += a[i] * points[j * 4 + i].y() * b[j];
- sz += a[i] * points[j * 4 + i].z() * b[j];
- }
- }
-
- // The normal is the cross-product of the two derivatives,
- // normalized to a unit vector.
- QVector3D n = QVector3D::normal(QVector3D(sx, sy, sz), QVector3D(tx, ty, tz));
- if (n.isNull()) {
- // A zero normal may occur if one of the patch edges is zero-length.
- // We correct for this by substituting an overall patch normal that
- // we compute from two of the sides that are not zero in length.
- QVector3D sides[4];
- QVector3D vectors[2];
- sides[0] = points[3] - points[0];
- sides[1] = points[15] - points[3];
- sides[2] = points[12] - points[15];
- sides[3] = points[0] - points[12];
- int i = 0;
- int j = 0;
- vectors[0] = QVector3D(1.0f, 0.0f, 0.0f);
- vectors[1] = QVector3D(0.0f, 1.0f, 0.0f);
- while (i < 2 && j < 4) {
- if (sides[j].isNull())
- ++j;
- else
- vectors[i++] = sides[j++];
- }
- n = QVector3D::normal(vectors[0], vectors[1]);
- }
- return n;
-}
-
-// Convert this patch into flat triangles.
-void QGLBezierPatch::convertToTriangles
- (QGeometryData *prim,
- qreal xtex, qreal ytex, qreal wtex, qreal htex)
-{
- // The edges are considered ok if they have a non-zero length.
- // Zero-length edges can occur in triangular-shaped patches.
- // There is no point generating triangles along such edges.
- bool edge1ok = (points[0] != points[3]);
- bool edge2ok = (points[0] != points[12]);
- bool edge3ok = (points[12] != points[15]);
- bool edge4ok = (points[15] != points[3]);
-
- // Find the mid-point on the patch by averaging the corners.
- QVector3D mid = (points[0] + points[3] + points[12] + points[15]) / 4.0f;
-
- // Allocate a triangle mesh vertex for the mid-point.
- int midIndex = prim->count();
- prim->appendVertex(mid);
- prim->appendNormal(normal(0.5f, 0.5f));
- prim->appendTexCoord
- (QVector2D(xtex + wtex / 2.0f, ytex + htex / 2.0f));
-
- // Divide the patch into 4 triangles pointing at the center.
- if (edge1ok)
- prim->appendIndices(indices[0], indices[1], midIndex);
- if (edge2ok)
- prim->appendIndices(indices[2], indices[0], midIndex);
- if (edge3ok)
- prim->appendIndices(indices[3], indices[2], midIndex);
- if (edge4ok)
- prim->appendIndices(indices[1], indices[3], midIndex);
-}
-
-// Sub-divide a Bezier curve (p1, p2, p3, p4) into two new
-// Bezier curves (l1, l2, l3, l4) and (r1, r2, r3, r4).
-static void subDivideBezierCurve
- (const QVector3D &p1, const QVector3D &p2,
- const QVector3D &p3, const QVector3D &p4,
- QVector3D &l1, QVector3D &l2, QVector3D &l3, QVector3D &l4,
- QVector3D &r1, QVector3D &r2, QVector3D &r3, QVector3D &r4)
-{
- l1 = p1;
- l2 = (p1 + p2) / 2.0f;
- QVector3D h = (p2 + p3) / 2.0f;
- l3 = (l2 + h) / 2.0f;
- r3 = (p3 + p4) / 2.0f;
- r2 = (h + r3) / 2.0f;
- l4 = r1 = (l3 + r2) / 2.0f;
- r4 = p4;
-}
-
-// Sub-divide this patch into four new patches. The triangle mesh
-// is used to allocate vertices for the corners of the new patches.
-void QGLBezierPatch::subDivide
- (QGLBezierPatch &patch1, QGLBezierPatch &patch2,
- QGLBezierPatch &patch3, QGLBezierPatch &patch4)
-{
- // Sub-divide the Bezier curves for the control rows to create
- // four rows of 8 control points. These define the left and
- // right halves of the patch.
- QVector3D row1[8];
- QVector3D row2[8];
- QVector3D row3[8];
- QVector3D row4[8];
- subDivideBezierCurve
- (points[0], points[1], points[2], points[3],
- row1[0], row1[1], row1[2], row1[3], row1[4], row1[5], row1[6], row1[7]);
- subDivideBezierCurve
- (points[4], points[5], points[6], points[7],
- row2[0], row2[1], row2[2], row2[3], row2[4], row2[5], row2[6], row2[7]);
- subDivideBezierCurve
- (points[8], points[9], points[10], points[11],
- row3[0], row3[1], row3[2], row3[3], row3[4], row3[5], row3[6], row3[7]);
- subDivideBezierCurve
- (points[12], points[13], points[14], points[15],
- row4[0], row4[1], row4[2], row4[3], row4[4], row4[5], row4[6], row4[7]);
-
- // Now sub-divide the 8 columns to create the four new patches.
- subDivideBezierCurve
- (row1[0], row2[0], row3[0], row4[0],
- patch1.points[0], patch1.points[4], patch1.points[8], patch1.points[12],
- patch3.points[0], patch3.points[4], patch3.points[8], patch3.points[12]);
- subDivideBezierCurve
- (row1[1], row2[1], row3[1], row4[1],
- patch1.points[1], patch1.points[5], patch1.points[9], patch1.points[13],
- patch3.points[1], patch3.points[5], patch3.points[9], patch3.points[13]);
- subDivideBezierCurve
- (row1[2], row2[2], row3[2], row4[2],
- patch1.points[2], patch1.points[6], patch1.points[10], patch1.points[14],
- patch3.points[2], patch3.points[6], patch3.points[10], patch3.points[14]);
- subDivideBezierCurve
- (row1[3], row2[3], row3[3], row4[3],
- patch1.points[3], patch1.points[7], patch1.points[11], patch1.points[15],
- patch3.points[3], patch3.points[7], patch3.points[11], patch3.points[15]);
- subDivideBezierCurve
- (row1[4], row2[4], row3[4], row4[4],
- patch2.points[0], patch2.points[4], patch2.points[8], patch2.points[12],
- patch4.points[0], patch4.points[4], patch4.points[8], patch4.points[12]);
- subDivideBezierCurve
- (row1[5], row2[5], row3[5], row4[5],
- patch2.points[1], patch2.points[5], patch2.points[9], patch2.points[13],
- patch4.points[1], patch4.points[5], patch4.points[9], patch4.points[13]);
- subDivideBezierCurve
- (row1[6], row2[6], row3[6], row4[6],
- patch2.points[2], patch2.points[6], patch2.points[10], patch2.points[14],
- patch4.points[2], patch4.points[6], patch4.points[10], patch4.points[14]);
- subDivideBezierCurve
- (row1[7], row2[7], row3[7], row4[7],
- patch2.points[3], patch2.points[7], patch2.points[11], patch2.points[15],
- patch4.points[3], patch4.points[7], patch4.points[11], patch4.points[15]);
-}
-
-void QGLBezierPatch::createNewCorners
- (QGLBezierPatch &patch1, QGLBezierPatch &patch2,
- QGLBezierPatch &patch3, QGLBezierPatch &patch4,
- QGeometryData *prim,
- qreal xtex, qreal ytex, qreal wtex, qreal htex)
-{
- // Add vertices for the new patch corners we have created.
- qreal hwtex = wtex / 2.0f;
- qreal hhtex = htex / 2.0f;
- int topPointIndex = prim->count();
- int leftPointIndex = topPointIndex + 1;
- int midPointIndex = topPointIndex + 2;
- int rightPointIndex = topPointIndex + 3;
- int bottomPointIndex = topPointIndex + 4;
-
- prim->appendVertex(patch1.points[3]);
- prim->appendNormal(normal(0.5f, 0.0f));
- prim->appendTexCoord(QVector2D(xtex + hwtex, ytex));
-
- prim->appendVertex(patch1.points[12]);
- prim->appendNormal(normal(0.0f, 0.5f));
- prim->appendTexCoord(QVector2D(xtex, ytex + hhtex));
-
- prim->appendVertex(patch1.points[15]);
- prim->appendNormal(normal(0.5f, 0.5f));
- prim->appendTexCoord(QVector2D(xtex + hwtex, ytex + hhtex));
-
- prim->appendVertex(patch2.points[15]);
- prim->appendNormal(normal(1.0f, 0.5f));
- prim->appendTexCoord(QVector2D(xtex + wtex, ytex + hhtex));
-
- prim->appendVertex(patch3.points[15]);
- prim->appendNormal(normal(0.5f, 1.0f));
- prim->appendTexCoord(QVector2D(xtex + hwtex, ytex + htex));
-
- // Copy the indices for the corners of the new patches.
- patch1.indices[0] = indices[0];
- patch1.indices[1] = topPointIndex;
- patch1.indices[2] = leftPointIndex;
- patch1.indices[3] = midPointIndex;
- patch2.indices[0] = topPointIndex;
- patch2.indices[1] = indices[1];
- patch2.indices[2] = midPointIndex;
- patch2.indices[3] = rightPointIndex;
- patch3.indices[0] = leftPointIndex;
- patch3.indices[1] = midPointIndex;
- patch3.indices[2] = indices[2];
- patch3.indices[3] = bottomPointIndex;
- patch4.indices[0] = midPointIndex;
- patch4.indices[1] = rightPointIndex;
- patch4.indices[2] = bottomPointIndex;
- patch4.indices[3] = indices[3];
-}
-
-// Recursively sub-divide a patch into triangles.
-void QGLBezierPatch::recursiveSubDivide
- (QGeometryData *prim,
- int depth, qreal xtex, qreal ytex, qreal wtex, qreal htex)
-{
- if (depth <= 1) {
- convertToTriangles(prim, xtex, ytex, wtex, htex);
- } else {
- QGLBezierPatch patch1, patch2, patch3, patch4;
- subDivide(patch1, patch2, patch3, patch4);
- createNewCorners(patch1, patch2, patch3, patch4, prim, xtex, ytex, wtex, htex);
- --depth;
- qreal hwtex = wtex / 2.0f;
- qreal hhtex = htex / 2.0f;
- patch1.recursiveSubDivide(prim, depth, xtex, ytex, hwtex, hhtex);
- patch2.recursiveSubDivide(prim, depth, xtex + hwtex, ytex, hwtex, hhtex);
- patch3.recursiveSubDivide(prim, depth, xtex, ytex + hhtex, hwtex, hhtex);
- patch4.recursiveSubDivide(prim, depth, xtex + hwtex, ytex + hhtex, hwtex, hhtex);
- }
-}
-
-void QGLBezierPatchesPrivate::subdivide(QGLBuilder *list) const
-{
- QGeometryData prim;
- int count = positions.size();
- for (int posn = 0; (posn + 15) < count; posn += 16) {
- // Construct a QGLBezierPatch object from the next high-level patch.
- QGLBezierPatch patch;
- int vertex;
- for (int vertex = 0; vertex < 16; ++vertex)
- patch.points[vertex] = positions[posn + vertex];
- QVector2D tex1, tex2;
- if (!textureCoords.isEmpty()) {
- tex1 = textureCoords[(posn / 16) * 2];
- tex2 = textureCoords[(posn / 16) * 2 + 1];
- } else {
- tex1 = QVector2D(0.0f, 0.0f);
- tex2 = QVector2D(1.0f, 1.0f);
- }
- qreal xtex = tex1.x();
- qreal ytex = tex1.y();
- qreal wtex = tex2.x() - xtex;
- qreal htex = tex2.y() - ytex;
- for (int corner = 0; corner < 4; ++corner) {
- vertex = posn + cornerOffsets[corner];
- QVector3D n = patch.normal(cornerS[corner], cornerT[corner]);
- patch.indices[corner] = prim.count();
- prim.appendVertex(patch.points[cornerOffsets[corner]]);
- prim.appendNormal(n);
- prim.appendTexCoord
- (QVector2D(xtex + wtex * cornerS[corner],
- ytex + htex * cornerT[corner]));
- }
-
- // Subdivide the patch and generate the final triangles.
- patch.recursiveSubDivide(&prim, subdivisionDepth,
- xtex, ytex, wtex, htex);
- }
- list->addTriangles(prim);
-}
-
-static inline qreal combineResults(qreal result, qreal t)
-{
- if (qIsNaN(result))
- return t;
- if (t >= 0.0f)
- return result < 0.0f ? t : qMin(result, t);
- else
- return result >= 0.0f ? result : qMax(result, t);
-}
-
-qreal QGLBezierPatch::intersection
- (qreal result, int depth, const QRay3D& ray, bool anyIntersection,
- qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc)
-{
- // Check the convex hull of the patch for an intersection.
- // If no intersection with the convex hull, then there is
- // no point subdividing this patch further.
- QBox3D box;
- for (int point = 0; point < 16; ++point)
- box.unite(points[point]);
- if (!box.intersects(ray))
- return result;
-
- // Are we at the lowest point of subdivision yet?
- if (depth <= 1) {
- // Divide the patch into two triangles and intersect with those.
- QTriangle3D triangle1(points[0], points[3], points[12]);
- qreal t = triangle1.intersection(ray);
- if (!qIsNaN(t)) {
- result = combineResults(result, t);
- if (result == t) {
- QVector2D uv = triangle1.uv(ray.point(t));
- QVector2D tp(xtex, ytex);
- QVector2D tq(xtex + wtex, ytex);
- QVector2D tr(xtex, ytex + htex);
- *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr;
- }
- } else {
- QTriangle3D triangle2(points[3], points[15], points[12]);
- qreal t = triangle2.intersection(ray);
- if (!qIsNaN(t)) {
- result = combineResults(result, t);
- if (result == t) {
- QVector2D uv = triangle2.uv(ray.point(t));
- QVector2D tp(xtex + wtex, ytex);
- QVector2D tq(xtex + wtex, ytex + htex);
- QVector2D tr(xtex, ytex + htex);
- *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr;
- }
- }
- }
- } else {
- // Subdivide the patch to find the point of intersection.
- QGLBezierPatch patch1, patch2, patch3, patch4;
- subDivide(patch1, patch2, patch3, patch4);
- --depth;
- qreal hwtex = wtex / 2.0f;
- qreal hhtex = htex / 2.0f;
- result = patch1.intersection
- (result, depth, ray, anyIntersection,
- xtex, ytex, hwtex, hhtex, tc);
- if (anyIntersection && !qIsNaN(result))
- return result;
- result = patch2.intersection
- (result, depth, ray, anyIntersection,
- xtex + hwtex, ytex, hwtex, hhtex, tc);
- if (anyIntersection && !qIsNaN(result))
- return result;
- result = patch3.intersection
- (result, depth, ray, anyIntersection,
- xtex, ytex + hhtex, hwtex, hhtex, tc);
- if (anyIntersection && !qIsNaN(result))
- return result;
- result = patch4.intersection
- (result, depth, ray, anyIntersection,
- xtex + hwtex, ytex + hhtex, hwtex, hhtex, tc);
- }
- return result;
-}
-
-qreal QGLBezierPatchesPrivate::intersection
- (const QRay3D &ray, bool anyIntersection, QVector2D *texCoord, int *bestPatch) const
-{
- int count = positions.size();
- qreal result = qSNaN();
- QVector2D tc;
- if (bestPatch)
- *bestPatch = -1;
- for (int posn = 0; (posn + 15) < count; posn += 16) {
- QGLBezierPatch patch;
- for (int vertex = 0; vertex < 16; ++vertex)
- patch.points[vertex] = positions[posn + vertex];
- QVector2D tex1, tex2;
- if (!textureCoords.isEmpty()) {
- tex1 = textureCoords[(posn / 16) * 2];
- tex2 = textureCoords[(posn / 16) * 2 + 1];
- } else {
- tex1 = QVector2D(0.0f, 0.0f);
- tex2 = QVector2D(1.0f, 1.0f);
- }
- qreal xtex = tex1.x();
- qreal ytex = tex1.y();
- qreal wtex = tex2.x() - xtex;
- qreal htex = tex2.y() - ytex;
- qreal prev = result;
- result = patch.intersection
- (result, subdivisionDepth, ray, anyIntersection,
- xtex, ytex, wtex, htex, &tc);
- if (bestPatch && result != prev)
- *bestPatch = posn / 16;
- if (anyIntersection && !qIsNaN(result))
- break;
- }
- if (texCoord && !qIsNaN(result))
- *texCoord = tc;
- return result;
-}
-
-/*!
- Constructs an empty Bezier patch list.
-
- \sa setPositions()
-*/
-QGLBezierPatches::QGLBezierPatches()
- : d_ptr(new QGLBezierPatchesPrivate())
-{
-}
-
-/*!
- Constructs a copy of \a other.
-
- \sa operator=()
-*/
-QGLBezierPatches::QGLBezierPatches(const QGLBezierPatches &other)
- : d_ptr(new QGLBezierPatchesPrivate(other.d_ptr.data()))
-{
-}
-
-/*!
- Destroys this Bezier patch list.
-*/
-QGLBezierPatches::~QGLBezierPatches()
-{
-}
-
-/*!
- Assigns \a other to this Bezier patch list.
-*/
-QGLBezierPatches &QGLBezierPatches::operator=
- (const QGLBezierPatches &other)
-{
- if (this != &other)
- d_ptr->copy(other.d_ptr.data());
- return *this;
-}
-
-/*!
- Returns the positions of the vertices in the Bezier patches.
-
- \sa setPositions(), textureCoords()
-*/
-QVector3DArray QGLBezierPatches::positions() const
-{
- Q_D(const QGLBezierPatches);
- return d->positions;
-}
-
-/*!
- Sets the \a positions of the vertices in the Bezier patches.
-
- \sa positions(), setTextureCoords()
-*/
-void QGLBezierPatches::setPositions(const QVector3DArray &positions)
-{
- Q_D(QGLBezierPatches);
- d->positions = positions;
-}
-
-/*!
- Returns the texture co-ordinates for the Bezier patches.
- Each patch consumes two elements from the texture
- co-ordinate array, defining the opposite corners.
-
- The default is an empty array, which indicates that each
- patch will generate texture co-ordinates in the range
- (0, 0) to (1, 1).
-
- \sa setTextureCoords(), positions()
-*/
-QVector2DArray QGLBezierPatches::textureCoords() const
-{
- Q_D(const QGLBezierPatches);
- return d->textureCoords;
-}
-
-/*!
- Sets the texture co-ordinates for the Bezier patches to
- the elements of \a textureCoords. Each patch consumes
- two elements from \a textureCoords, defining the opposite
- corners.
-
- If \a textureCoords is empty, then each patch will generate
- texture co-ordinates in the range (0, 0) to (1, 1).
-
- \sa textureCoords(), setPositions()
-*/
-void QGLBezierPatches::setTextureCoords(const QVector2DArray &textureCoords)
-{
- Q_D(QGLBezierPatches);
- d->textureCoords = textureCoords;
-}
-
-/*!
- Returns the depth of subdivision to use when converting the
- Bezier geometry into triangles. The default value is 4.
-
- \sa setSubdivisionDepth()
-*/
-int QGLBezierPatches::subdivisionDepth() const
-{
- Q_D(const QGLBezierPatches);
- return d->subdivisionDepth;
-}
-
-/*!
- Sets the depth of subdivision to use when converting the
- Bezier geometry into triangles to \a value.
-
- \sa subdivisionDepth()
-*/
-void QGLBezierPatches::setSubdivisionDepth(int value)
-{
- Q_D(QGLBezierPatches);
- d->subdivisionDepth = value;
-}
-
-/*!
- Transforms the positions() in this Bezier geometry object
- according to \a matrix.
-
- \sa transformed()
-*/
-void QGLBezierPatches::transform(const QMatrix4x4 &matrix)
-{
- Q_D(QGLBezierPatches);
- d->positions.transform(matrix);
-}
-
-/*!
- Returns a new Bezier geometry object that results from transforming
- this object's positions() according to \a matrix.
-
- \sa transform()
-*/
-QGLBezierPatches QGLBezierPatches::transformed(const QMatrix4x4 &matrix) const
-{
- QGLBezierPatches result(*this);
- result.d_ptr->positions.transform(matrix);
- return result;
-}
-
-/*!
- Returns true if \a ray intersects this Bezier geometry object;
- false otherwise.
-
- \sa intersection()
-*/
-bool QGLBezierPatches::intersects(const QRay3D &ray) const
-{
- Q_D(const QGLBezierPatches);
- return !qIsNaN(d->intersection(ray, true, 0, 0));
-}
-
-/*!
- Returns the t value at which \a ray intersects this Bezier
- geometry object, or not-a-number if there is no intersection.
-
- When the \a ray intersects this object, the return value is a
- parametric value that can be passed to QRay3D::point() to determine
- the actual intersection point, as shown in the following example:
-
- \code
- qreal t = patches.intersection(ray);
- QVector3D pt;
- if (qIsNaN(t)) {
- qWarning("no intersection occurred");
- else
- pt = ray.point(t);
- \endcode
-
- If \a ray intersects the object multiple times, the returned
- t will be the smallest t value, corresponding to the first
- intersection of the \a ray with the object. The t value may
- be negative if the first intersection occurs in the reverse
- direction of \a ray.
-
- The intersection is determined by subdividing the patches into
- triangles and intersecting with those triangles. A pruning
- algorithm is used to discard patches whose convex hull do not
- intersect with \a ray.
-
- If \a texCoord is not null, then it will return the texture
- co-ordinate of the intersection point.
-
- If \a patch is not null, then it will return the index of the
- patch that contains the intersection, or -1 if there is no
- intersection.
-
- \sa intersects()
-*/
-qreal QGLBezierPatches::intersection(const QRay3D &ray, QVector2D *texCoord, int *patch) const
-{
- Q_D(const QGLBezierPatches);
- return d->intersection(ray, false, texCoord, patch);
-}
-
-/*!
- \relates QGLBezierPatches
-
- Subdivides the Bezier patch data in \a patches into triangles
- and adds them to the specified display \a list.
-*/
-QGLBuilder &operator<<(QGLBuilder &list, const QGLBezierPatches &patches)
-{
- patches.d_ptr->subdivide(&list);
- return list;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglbezierpatches.h b/src/threed/geometry/qglbezierpatches.h
deleted file mode 100644
index 4a4d042c..00000000
--- a/src/threed/geometry/qglbezierpatches.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLBEZIERPATCHES_H
-#define QGLBEZIERPATCHES_H
-
-#include "qvector2darray.h"
-#include "qvector3darray.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLBezierPatchesPrivate;
-class QGLBuilder;
-class QRay3D;
-
-class Q_QT3D_EXPORT QGLBezierPatches
-{
-public:
- QGLBezierPatches();
- QGLBezierPatches(const QGLBezierPatches &other);
- virtual ~QGLBezierPatches();
-
- QGLBezierPatches &operator=(const QGLBezierPatches &other);
-
- QVector3DArray positions() const;
- void setPositions(const QVector3DArray &positions);
-
- QVector2DArray textureCoords() const;
- void setTextureCoords(const QVector2DArray &textureCoords);
-
- int subdivisionDepth() const;
- void setSubdivisionDepth(int value);
-
- void transform(const QMatrix4x4 &matrix);
- QGLBezierPatches transformed(const QMatrix4x4 &matrix) const;
-
- bool intersects(const QRay3D &ray) const;
- qreal intersection(const QRay3D &ray, QVector2D *texCoord = 0, int *patch = 0) const;
-
-private:
- QScopedPointer<QGLBezierPatchesPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLBezierPatches)
-
- friend Q_QT3D_EXPORT QGLBuilder &operator<<(QGLBuilder &list, const QGLBezierPatches &patches);
-};
-
-Q_QT3D_EXPORT QGLBuilder &operator<<(QGLBuilder &list, const QGLBezierPatches &patches);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/qglbuilder.cpp b/src/threed/geometry/qglbuilder.cpp
deleted file mode 100644
index 1a73d9ca..00000000
--- a/src/threed/geometry/qglbuilder.cpp
+++ /dev/null
@@ -1,1382 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglbuilder.h"
-#include "qglbuilder_p.h"
-#include "qglsection_p.h"
-#include "qglmaterialcollection.h"
-#include "qglpainter.h"
-#include "qgeometrydata.h"
-#include "qvector_utils_p.h"
-
-#include <QtGui/qvector2d.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLBuilder
- \brief The QGLBuilder class constructs geometry for efficient display.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- \tableofcontents
-
- Use a QGLBuilder to build up vertex, index, texture and other data
- during application initialization. The finalizedSceneNode() function
- returns an optimized scene which can be efficiently and flexibly
- displayed during frames of rendering. It is suited to writing loaders
- for 3D models, and for programatically creating geometry.
-
- \section1 Geometry Building
-
- QGLBuilder makes the job of getting triangles on the GPU simple. It
- calculates indices and normals for you, then uploads the data. While
- it has addQuads() and other functions to deal with quads, all data is
- represented as triangles for portability.
-
- The simplest way to use QGLBuilder is to send a set of geometry
- values to it using QGeometryData in the constructor:
-
- \code
- MyView::MyView() : QGLView()
- {
- // in the constructor construct a builder on the stack
- QGLBuilder builder;
- QGeometryData triangle;
- QVector3D a(2, 2, 0);
- QVector3D b(-2, 2, 0);
- QVector3D c(0, -2, 0);
- triangle.appendVertex(a, b, c);
-
- // When adding geometry, QGLBuilder automatically creates lighting normals
- builder << triangle;
-
- // obtain the scene from the builder
- m_scene = builder.finalizedSceneNode();
-
- // apply effects at app initialization time
- QGLMaterial *mat = new QGLMaterial;
- mat->setDiffuseColor(Qt::red);
- m_scene->setMaterial(mat);
- }
- \endcode
-
- Then during rendering the scene is used to display the results:
- \code
- MyView::paintGL(QGLPainter *painter)
- {
- m_scene->draw(painter);
- }
- \endcode
-
- QGLBuilder automatically generates index values and normals
- on-the-fly during geometry building. During building, simply send
- primitives to the builder as a sequence of vertices, and
- vertices that are the same will be referenced by a single index
- automatically.
-
- Primitives will have standard normals generated automatically
- based on vertex winding.
-
- Consider the following code for OpenGL to draw a quad with corner
- points A, B, C and D :
-
- \code
- float vertices[12] =
- {
- -1.0, -1.0, -1.0, // A
- 1.0, -1.0, -1.0, // B
- 1.0, 1.0, 1.0, // C
- -1.0, 1.0, 1.0 // D
- };
- float normals[12] = { 0.0f };
- for (int i = 0; i < 12; i += 3)
- {
- normals[i] = 0.0;
- normals[i+1] = -sqrt(2.0);
- normals[i+2] = sqrt(2.0);
- }
- GLuint indices[6] = {
- 0, 1, 2, // triangle A-B-C
- 0, 2, 3 // triangle A-C-D
- };
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, vertices);
- glNormalPointer(3, GL_FLOAT, 0, normals);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, indices);
- \endcode
-
- With QGLBuilder this code becomes:
-
- \code
- float vertices[12] =
- {
- -1.0, -1.0, -1.0, // A
- 1.0, -1.0, -1.0, // B
- 1.0, 1.0, 1.0, // C
- -1.0, 1.0, 1.0 // D
- };
- QGLBuilder quad;
- QGeometryData data;
- data.appendVertexArray(QArray<QVector3D>::fromRawData(
- reinterpret_cast<const QVector3D*>(vertices), 4));
- quad.addQuads(data);
- \endcode
-
- The data primitive is added to the list, as two triangles, indexed to
- removed the redundant double storage of B & C - just the same as the
- OpenGL code.
-
- QGLBuilder will also calculate a normal for the quad and apply it
- to the vertices.
-
- In this trivial example the indices are easily calculated, however
- in more complex geometry it is easy to introduce bugs by trying
- to manually control indices. Extra work is required to generate,
- track and store the index values correctly.
-
- Bugs such as trying to index two vertices with different data -
- one with texture data and one without - into one triangle can
- easily result. The picture becomes more difficult when smoothing
- groups are introduced - see below.
-
- Using indices is always preferred since it saves space on the GPU,
- and makes the geometry perform faster during application run time.
-
- \section2 Removing Epsilon Errors
-
- Where vertices are generated by modelling packages or tools, or
- during computation in code, very frequently rounding errors will
- result in several vertices being generated that are actually
- the same vertex but are separated by tiny amounts. At best these
- duplications waste space on the GPU but at worst can introduce
- visual artifacts that mar the image displayed.
-
- Closing paths, generating solids of rotation, or moving model
- sections out and back can all introduce these types of epsilon
- errors, resulting in "cracks" or artifacts on display.
-
- QGLBuilder's index generation process uses a fuzzy match that
- coalesces all vertex values at a point - even if they are out by
- a tiny amount - and references them with a single index.
-
- \section2 Lighting Normals and Null Triangles
-
- QGLBuilder functions calculate lighting normals, when building
- geometry. This saves the application programmer from having to write
- code to calculate them. Normals for each triangle (a, b, c) are
- calculated as the QVector3D::normal(a, b, c).
-
- If lighting normals are explicitly supplied when using QGLBuilder,
- then this calculation is not done. This may save on build time.
-
- As an optimization, QGLBuilder skips null triangles, that is ones
- with zero area, where it can. Such triangles generate no fragments on
- the GPU, and thus do not display but nonetheless can take up space
- and processing power.
-
- Null triangles can easily occur when calculating vertices results
- in two vertices coinciding, or three vertices lying on the same line.
-
- This skipping is done using the lighting normals cross-product. If the
- cross-product is a null vector then the triangle is null.
-
- When lighting normals are specified explicitly the skipping
- optimization is suppressed, so if for some reason null triangles are
- required to be retained, then specify normals for each logical vertex.
-
- See the documentation below of the individual addTriangle() and other
- functions for more details.
-
- \section2 Raw Triangle Mode
-
- Where generation of indices and normals is not needed - for example if
- porting an existing application, it is possible to do a raw import of
- triangle data, without using any of QGLBuilder's processing.
-
- To do this ensure that indices are placed in the QGeometryData passed to
- the addTriangles() function, and this will trigger \bold{raw triangle} mode.
-
- When adding triangles in this way ensure that all appropriate values
- have been correctly set, and that the normals, indices and other data
- are correctly calculated, since no checking is done.
-
- When writing new applications, simply leave construction of normals and
- indices to the QGLBuilder
-
- \section1 Rendering and QGLSceneNode items.
-
- QGLSceneNodes are used to manage application of local transformations,
- materials and effects.
-
- QGLBuilder generates a root level QGLSceneNode, which can be accessed
- with the sceneNode() function. Under this a new node is created for
- each section of geometry, and also by using pushNode() and popNode().
-
- To organize geometry for painting with different materials and effects
- call the newNode() function:
-
- \code
- QGLSceneNode *box = builder.newNode();
- box->setMaterial(wood);
- \endcode
-
- Many nodes may be created this way, but they will be optimized into
- a small number of buffers under the one scene when the
- finalizedSceneNode() function is called.
-
- \image soup.png
-
- Here the front can is a set of built geometry and the other two are
- scene nodes that reference it, without copying any geometry.
-
- \snippet qt3d/builder/builder.cpp 0
-
- QGLSceneNodes can be used after the builder is created to cheaply
- copy and redisplay the whole scene. Or to reference parts of the geometry
- use the functions newNode() or pushNode() and popNode() to manage
- QGLSceneNode generation while building geometry.
-
- To draw the resulting built geometry simply call the draw method of the
- build geometry.
-
- \snippet qt3d/builder/builder.cpp 1
-
- Call the \l{QGLSceneNode::palette()}{palette()} function on the sceneNode()
- to get the QGLMaterialCollection for the node, and place textures
- and materials into it.
-
- Built geometry will typically share the one palette. Either create a
- palette, and pass it to the \l{QGLBuilder::QGLBuilder()}{constructor};
- or pass no arguments to the constructor and the QGLBuilder
- will create a palette:
-
- \snippet qt3d/builder/builder.cpp 2
-
- These may then be applied as needed throughout the building of the
- geometry using the integer reference, \c{canMat} in the above code.
-
- See the QGLSceneNode documentation for more.
-
- \section1 Using Sections
-
- During initialization of the QGLBuilder, while accumulating
- geometry, the geometry data in a QGLBuilder is placed into
- sections - there must be at least one section.
-
- Call the newSection() function to create a new section:
-
- \snippet qt3d/builder/builder.cpp 3
-
- Here separate sections for the rounded outside cylinder and flat top and
- bottom of the soup can model makes for the appearance of a sharp edge
- between them. If the sides and top and bottom were in the same section
- QGLBuilder would attempt to average the normals around the edge resulting
- in an unrealistic effect.
-
- In 3D applications this concept is referred to as
- \l{http://www.google.com/search?smoothing+groups}{smoothing groups}. Within
- a section (smoothing group) all normals are averaged making it appear
- as one smoothly shaded surface.
-
- The can has 3 smoothing groups - bottom, top and sides.
-
- This mesh of a Q is a faceted model - it has 0 smoothing groups:
-
- \image faceted-q.png
-
- To create geometry with a faceted appearance call newSection() with
- an argument of QGL::Faceted thus \c{newSection(QGL::Faceted)}.
-
- Faceted geometry is suitable for small models, where hard edges are
- desired between every face - a dice, gem or geometric solid for example.
-
- If no section has been created when geometry is added a new section is
- created automatically. This section will have its smoothing set
- to QGL::Smooth.
-
- To create a faceted appearance rather than accepting the automatically
- created section the << operator can also be used:
-
- \code
- QGLBuilder builder;
- QGeometryData triangles;
- triangles.appendVertices(a, b, c);
- builder << QGL::Faceted << triangles;
- \endcode
-
- \section2 Geometry Data in a Section
-
- Management of normals and vertices for smoothing, and other data is
- handled automatically by the QGLBuilder instance.
-
- Within a section, incoming geometry data will be coalesced and
- indices created to reference the fewest possible copies of the vertex
- data. For example, in smooth geometry all copies of a vertex are
- coalesced into one, and referenced by indices.
-
- One of the few exceptions to this is the case where texture data forms
- a \i seam and a copy of a vertex must be created to carry the two
- texture coordinates either side of the seam.
-
- \image texture-seam.png
-
- Coalescing has the effect of packing geometry data into the
- smallest space possible thus improving cache coherence and performance.
-
- Again all this is managed automatically by QGLBuilder and all
- that is required is to create smooth or faceted sections, and add
- geometry to them.
-
- Each QGLSection references a contiguous range of vertices in a
- QGLBuilder.
-
- \section1 Finalizing and Retrieving the Scene
-
- Once the geometry has been accumulated in the QGLBuilder instance, the
- finalizedSceneNode() method must be called to retrieve the optimized
- scene. This function serves to normalize the geometry and optimize
- it for display.
-
- While it may be convenient to get pointers to sub nodes in the scene
- during construction, it is important to retrieve the root of the scene
- so that the memory consumed by the scene can be recovered. The builder
- will create a QGLMaterialCollection; and there may be geometry, materials
- and other resources: these are all parented onto the root scene node.
- These can easily be recovered by deleting the root scene node:
-
- \code
- MyView::MyView() : QGLView()
- {
- // in the constructor construct a builder on the stack
- QGLBuilder builder;
-
- // add geometry as shown above
- builder << triangles;
-
- // obtain the scene from the builder & take ownership
- m_scene = builder.finalizedSceneNode();
- }
-
- MyView::~MyView()
- {
- // recover all scene resources
- delete m_scene;
- }
- \endcode
-
- Alternatively set the scene's parent to ensure resource recovery
- \c{m_scene->setParent(this)}.
-
-
-*/
-
-QGLBuilderPrivate::QGLBuilderPrivate(QGLBuilder *parent)
- : currentSection(0)
- , currentNode(0)
- , rootNode(0)
- , defThreshold(5)
- , q(parent)
-{
-}
-
-QGLBuilderPrivate::~QGLBuilderPrivate()
-{
- qDeleteAll(sections);
- if (rootNode)
- {
- qWarning("Destroying QGLBuilder but finalizedSceneNode() not called");
- delete rootNode;
- }
-}
-
-/*!
- Construct a new QGLBuilder using \a materials for the palette. If the
- \a materials argument is null, then a new palette is created.
-*/
-QGLBuilder::QGLBuilder(QGLMaterialCollection *materials)
- : dptr(new QGLBuilderPrivate(this))
-{
- dptr->rootNode = new QGLSceneNode;
- if (!materials)
- materials = new QGLMaterialCollection(dptr->rootNode);
- dptr->rootNode->setPalette(materials);
-}
-
-/*!
- Destroys this QGLBuilder recovering any resources.
-*/
-QGLBuilder::~QGLBuilder()
-{
- delete dptr;
-}
-
-/*!
- Helper function to calculate the normal for and set it on vertices
- in \a i, \a j and \a k in triangle data \a p. If the triangle in
- data \a p is a null triangle (area == 0) then the function returns
- false, otherwise it returns true.
-*/
-static inline void setNormals(int i, int j, int k, QGeometryData &p, const QVector3D &n)
-{
- p.normal(i) = n;
- p.normal(j) = n;
- p.normal(k) = n;
-}
-
-static bool qCalculateNormal(int i, int j, int k, QGeometryData &p, QVector3D *vec = 0)
-{
- QVector3D norm;
- QVector3D *n = &norm;
- if (vec)
- n = vec;
- bool nullTriangle = false;
- *n = QVector3D::crossProduct(p.vertexAt(j) - p.vertexAt(i),
- p.vertexAt(k) - p.vertexAt(j));
- if (qFskIsNull(n->x()))
- n->setX(0.0f);
- if (qFskIsNull(n->y()))
- n->setY(0.0f);
- if (qFskIsNull(n->z()))
- n->setZ(0.0f);
- if (n->isNull())
- {
- nullTriangle = true;
- }
- else
- {
- setNormals(i, j, k, p, *n);
- }
- return nullTriangle;
-}
-
-/*!
- \internal
- Helper function to actually add the vertices to geometry.
-*/
-void QGLBuilderPrivate::addTriangle(int i, int j, int k,
- const QGeometryData &p, int &count)
-{
- if (currentSection == 0)
- q->newSection();
- QLogicalVertex a(p, i);
- QLogicalVertex b(p, j);
- QLogicalVertex c(p, k);
- currentSection->append(a, b, c);
- count += 3;
-}
-
-/*!
- Add \a triangles - a series of one or more triangles - to this builder.
-
- The data is broken into groups of 3 vertices, each processed as a triangle.
-
- If \a triangles has less than 3 vertices this function exits without
- doing anything. Any vertices at the end of the list under a multiple
- of 3 are ignored.
-
- If no normals are supplied in \a triangles, a normal is calculated; as
- the cross-product \c{(b - a) x (c - a)}, for each group of 3
- logical vertices \c{a(triangle, i), b(triangle, i+1), c(triangle, i+2)}.
-
- In the case of a degenerate triangle, where the cross-product is null,
- that triangle is skipped. Supplying normals suppresses this behaviour
- (and means any degenerate triangles will be added to the geometry).
-
- \bold{Raw Triangle Mode}
-
- If \a triangles has indices specified then no processing of any kind is
- done and all the geometry is simply dumped in to the builder.
-
- This \bold{raw triangle} mode is for advanced use, and it is assumed that
- the user knows what they are doing, in particular that the indices
- supplied are correct, and normals are supplied and correct.
-
- Normals are not calculated in raw triangle mode, and skipping of null
- triangles is likewise not performed. See the section on
- \l{raw-triangle-mode}{raw triangle mode}
- in the class documentation above.
-
- \sa addQuads(), operator>>()
-*/
-void QGLBuilder::addTriangles(const QGeometryData &triangles)
-{
- if (triangles.count() < 3)
- return;
- if (triangles.indexCount() > 0)
- {
- // raw triangle mode
- if (dptr->currentSection == 0)
- newSection();
- dptr->currentSection->appendGeometry(triangles);
- dptr->currentSection->appendIndices(triangles.indices());
- dptr->currentNode->setCount(dptr->currentNode->count() + triangles.indexCount());
- }
- else
- {
- QGeometryData t = triangles;
- bool calcNormal = !t.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(t.count());
- t.appendNormalArray(nm);
- }
- bool skip = false;
- int k = 0;
- for (int i = 0; i < t.count() - 2; i += 3)
- {
- if (calcNormal)
- skip = qCalculateNormal(i, i+1, i+2, t);
- if (!skip)
- dptr->addTriangle(i, i+1, i+2, t, k);
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
- }
-}
-
-/*!
- Add \a quads - a series of one or more quads - to this builder.
-
- If \a quads has less than four vertices this function exits without
- doing anything.
-
- One normal per quad is calculated if \a quads does not have normals.
- For this reason quads should have all four vertices in the same plane.
- If the vertices do not lie in the same plane, use addTriangleStrip()
- to add two adjacent triangles instead.
-
- Since internally \l{geometry-building}{quads are stored as two triangles},
- each quad is actually divided in half into two triangles.
-
- Degenerate triangles are skipped in the same way as addTriangles().
-
- \sa addTriangles(), addTriangleStrip()
-*/
-void QGLBuilder::addQuads(const QGeometryData &quads)
-{
- if (quads.count() < 4)
- return;
- QGeometryData q = quads;
- bool calcNormal = !q.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(q.count());
- q.appendNormalArray(nm);
- }
- bool skip = false;
- int k = 0;
- QVector3D norm;
- for (int i = 0; i < q.count(); i += 4)
- {
- if (calcNormal)
- skip = qCalculateNormal(i, i+1, i+2, q, &norm);
- if (!skip)
- dptr->addTriangle(i, i+1, i+2, q, k);
- if (skip)
- skip = qCalculateNormal(i, i+2, i+3, q, &norm);
- if (!skip)
- {
- if (calcNormal)
- setNormals(i, i+2, i+3, q, norm);
- dptr->addTriangle(i, i+2, i+3, q, k);
- }
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- Adds to this section a set of connected triangles defined by \a fan.
-
- N triangular faces are generated, where \c{N == fan.count() - 2}. Each
- face contains the 0th vertex in \a fan, followed by the i'th and i+1'th
- vertex - where i takes on the values from 1 to \c{fan.count() - 1}.
-
- If \a fan has less than three vertices this function exits without
- doing anything.
-
- This function is similar to the OpenGL mode GL_TRIANGLE_FAN. It
- generates a number of triangles all sharing one common vertex, which
- is the 0'th vertex of the \a fan.
-
- Normals are calculated as for addTriangle(), given the above ordering.
- There is no requirement or assumption that all triangles lie in the
- same plane. Degenerate triangles are skipped in the same way as
- addTriangles().
-
- \sa addTriangulatedFace()
-*/
-void QGLBuilder::addTriangleFan(const QGeometryData &fan)
-{
- if (fan.count() < 3)
- return;
- QGeometryData f = fan;
- bool calcNormal = !f.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(f.count());
- f.appendNormalArray(nm);
- }
- int k = 0;
- bool skip = false;
- for (int i = 1; i < f.count() - 1; ++i)
- {
- if (calcNormal)
- skip = qCalculateNormal(0, i, i+1, f);
- if (!skip)
- dptr->addTriangle(0, i, i+1, f, k);
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- Adds to this section a set of connected triangles defined by \a strip.
-
- N triangular faces are generated, where \c{N == strip.count() - 2}.
- The triangles are generated from vertices 0, 1, & 2, then 2, 1 & 3,
- then 2, 3 & 4, and so on. In other words every second triangle has
- the first and second vertices switched, as a new triangle is generated
- from each successive set of three vertices.
-
- If \a strip has less than three vertices this function exits without
- doing anything.
-
- Normals are calculated as for addTriangle(), given the above ordering.
-
- This function is very similar to the OpenGL mode GL_TRIANGLE_STRIP. It
- generates triangles along a strip whose two sides are the even and odd
- vertices.
-
- \sa addTriangulatedFace()
-*/
-void QGLBuilder::addTriangleStrip(const QGeometryData &strip)
-{
- if (strip.count() < 3)
- return;
- QGeometryData s = strip;
- bool calcNormal = !s.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(s.count());
- s.appendNormalArray(nm);
- }
- bool skip = false;
- int k = 0;
- for (int i = 0; i < s.count() - 2; ++i)
- {
- if (i % 2)
- {
- if (calcNormal)
- skip = qCalculateNormal(i+1, i, i+2, s);
- if (!skip)
- dptr->addTriangle(i+1, i, i+2, s, k);
- }
- else
- {
- if (calcNormal)
- skip = qCalculateNormal(i, i+1, i+2, s);
- if (!skip)
- dptr->addTriangle(i, i+1, i+2, s, k);
- }
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- Adds to this section a set of quads defined by \a strip.
-
- If \a strip has less than four vertices this function exits without
- doing anything.
-
- The first quad is formed from the 0'th, 2'nd, 3'rd and 1'st vertices.
- The second quad is formed from the 2'nd, 4'th, 5'th and 3'rd vertices,
- and so on, as shown in this diagram:
-
- \image quads.png
-
- One normal per quad is calculated if \a strip does not have normals.
- For this reason quads should have all four vertices in the same plane.
- If the vertices do not lie in the same plane, use addTriangles() instead.
-
- Since internally \l{geometry-building}{quads are stored as two triangles},
- each quad is actually divided in half into two triangles.
-
- Degenerate triangles are skipped in the same way as addTriangles().
-
- \sa addQuads(), addTriangleStrip()
-*/
-void QGLBuilder::addQuadStrip(const QGeometryData &strip)
-{
- if (strip.count() < 4)
- return;
- QGeometryData s = strip;
- bool calcNormal = !s.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(s.count());
- s.appendNormalArray(nm);
- }
- bool skip = false;
- QVector3D norm;
- int k = 0;
- for (int i = 0; i < s.count() - 3; i += 2)
- {
- if (calcNormal)
- skip = qCalculateNormal(i, i+2, i+3, s, &norm);
- if (!skip)
- dptr->addTriangle(i, i+2, i+3, s, k);
- if (skip)
- skip = qCalculateNormal(i, i+3, i+1, s, &norm);
- if (!skip)
- {
- if (calcNormal)
- setNormals(i, i+3, i+1, s, norm);
- dptr->addTriangle(i, i+3, i+1, s, k);
- }
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- Adds to this section a polygonal face made of triangular sub-faces,
- defined by \a face. The 0'th vertex is used for the center, while
- the subsequent vertices form the perimeter of the face, which must
- at minimum be a triangle.
-
- If \a face has less than four vertices this function exits without
- doing anything.
-
- This function provides functionality similar to the OpenGL mode GL_POLYGON,
- except it divides the face into sub-faces around a \bold{central point}.
- The center and perimeter vertices must lie in the same plane (unlike
- triangle fan). If they do not normals will be incorrectly calculated.
-
- \image triangulated-face.png
-
- Here the sub-faces are shown divided by green lines. Note how this
- function handles some re-entrant (non-convex) polygons, whereas
- addTriangleFan will not support such polygons.
-
- If required, the center point can be calculated using the center() function
- of QGeometryData:
-
- \code
- QGeometryData face;
- face.appendVertex(perimeter.center()); // perimeter is a QGeometryData
- face.appendVertices(perimeter);
- builder.addTriangulatedFace(face);
- \endcode
-
- N sub-faces are generated where \c{N == face.count() - 2}.
-
- Each triangular sub-face consists of the center; followed by the \c{i'th}
- and \c{((i + 1) % N)'th} vertex. The last face generated then is
- \c{(center, face[N - 1], face[0]}, the closing face. Note that the closing
- face is automatically created, unlike addTriangleFan().
-
- If no normals are supplied in the vertices of \a face, normals are
- calculated as per addTriangle(). One normal is calculated, since a
- faces vertices lie in the same plane.
-
- Degenerate triangles are skipped in the same way as addTriangles().
-
- \sa addTriangleFan(), addTriangles()
-*/
-void QGLBuilder::addTriangulatedFace(const QGeometryData &face)
-{
- if (face.count() < 4)
- return;
- QGeometryData f;
- f.appendGeometry(face);
- int cnt = f.count();
- bool calcNormal = !f.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(cnt);
- f.appendNormalArray(nm);
- }
- bool skip = false;
- QVector3D norm;
- int k = 0;
- for (int i = 1; i < cnt; ++i)
- {
- int n = i + 1;
- if (n == cnt)
- n = 1;
- if (calcNormal)
- {
- skip = qCalculateNormal(0, i, n, f);
- if (norm.isNull() && !skip)
- {
- norm = f.normalAt(0);
- for (int i = 0; i < cnt; ++i)
- f.normal(i) = norm;
- }
- }
- if (!skip)
- dptr->addTriangle(0, i, n, f, k);
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- Add a series of quads by 'interleaving' \a top and \a bottom.
-
- This function behaves like quadStrip(), where the odd-numbered vertices in
- the input primitive are from \a top and the even-numbered vertices from
- \a bottom.
-
- It is trivial to do extrusions using this function:
-
- \code
- // create a series of quads for an extruded edge along -Y
- addQuadsInterleaved(topEdge, topEdge.translated(QVector3D(0, -1, 0));
- \endcode
-
- N quad faces are generated where \c{N == min(top.count(), bottom.count() - 1}.
- If \a top or \a bottom has less than 2 elements, this functions does
- nothing.
-
- Each face is formed by the \c{i'th} and \c{(i + 1)'th}
- vertices of \a bottom, followed by the \c{(i + 1)'th} and \c{i'th}
- vertices of \a top.
-
- If the vertices in \a top and \a bottom are the perimeter vertices of
- two polygons then this function can be used to generate quads which form
- the sides of a \l{http://en.wikipedia.org/wiki/Prism_(geometry)}{prism}
- with the polygons as the prisms top and bottom end-faces.
-
- \image quad-extrude.png
-
- In the diagram above, the \a top is shown in orange, and the \a bottom in
- dark yellow. The first generated quad, (a, b, c, d) is generated in
- the order shown by the blue arrow.
-
- To create such a extruded prismatic solid, complete with top and bottom cap
- polygons, given just the top edge do this:
- \code
- QGeometryData top = buildTopEdge();
- QGeometryData bottom = top.translated(QVector3D(0, 0, -1));
- builder.addQuadsInterleaved(top, bottom);
- builder.addTriangulatedFace(top);
- builder.addTriangulatedFace(bottom.reversed());
- \endcode
- The \a bottom QGeometryData must be \bold{reversed} so that the correct
- winding for an outward facing polygon is obtained.
-*/
-void QGLBuilder::addQuadsInterleaved(const QGeometryData &top,
- const QGeometryData &bottom)
-{
- if (top.count() < 2 || bottom.count() < 2)
- return;
- QGeometryData zipped = bottom.interleavedWith(top);
- bool calcNormal = !zipped.hasField(QGL::Normal);
- if (calcNormal)
- {
- QVector3DArray nm(zipped.count());
- zipped.appendNormalArray(nm);
- }
- bool skip = false;
- QVector3D norm;
- int k = 0;
- for (int i = 0; i < zipped.count() - 2; i += 2)
- {
- if (calcNormal)
- skip = qCalculateNormal(i, i+2, i+3, zipped, &norm);
- if (!skip)
- dptr->addTriangle(i, i+2, i+3, zipped, k);
- if (skip)
- skip = qCalculateNormal(i, i+3, i+1, zipped, &norm);
- if (!skip)
- {
- if (calcNormal)
- setNormals(i, i+3, i+1, zipped, norm);
- dptr->addTriangle(i, i+3, i+1, zipped, k);
- }
- }
- dptr->currentNode->setCount(dptr->currentNode->count() + k);
-}
-
-/*!
- \fn void QGLBuilder::addPane(QSizeF size)
- Convenience function to create a quad centered on the origin,
- lying in the Z=0 plane, with width (x dimension) and height
- (y dimension) specified by \a size.
-*/
-
-/*!
- \fn void QGLBuilder::addPane(qreal size)
- Convenience method to add a single quad of dimensions \a size wide by
- \a size high in the z = 0 plane, centered on the origin. The quad has
- texture coordinates of (0, 0) at the bottom left and (1, 1) at the top
- right. The default value for \a size is 1.0, resulting in a quad
- from QVector3D(-0.5, -0.5, 0.0) to QVector3D(0.5, 0.5, 0.0).
-*/
-
-/*!
- \internal
-*/
-void QGLBuilderPrivate::adjustSectionNodes(QGLSection *sec,
- int offset, const QGeometryData &geom)
-{
- QList<QGLSceneNode*> children = sec->nodes();
- QList<QGLSceneNode*>::iterator it = children.begin();
- QList<QGLSceneNode*> deleted;
- for ( ; it != children.end(); ++it)
- adjustNodeTree(*it, offset, geom, deleted);
-}
-
-/*!
- \internal
- Adjust \a top by incrementing its start by \a offset, and setting its
- geometry to \a geom. Find the cumulative total of indexes -
- QGLSceneNode::count() - for \a top and all its children. If this total is
- equal to zero, then delete that node.
-*/
-int QGLBuilderPrivate::adjustNodeTree(QGLSceneNode *top,
- int offset, const QGeometryData &geom,
- QList<QGLSceneNode*> &deleted)
-{
- int totalItems = 0;
- if (top && !deleted.contains(top))
- {
- top->setStart(top->start() + offset);
- top->setGeometry(geom);
- totalItems = top->count();
- QList<QGLSceneNode*> children = top->children();
- QList<QGLSceneNode*>::iterator it = children.begin();
- for ( ; it != children.end(); ++it)
- {
- totalItems += adjustNodeTree(*it, offset, geom, deleted);
- }
- if (totalItems == 0 && top->objectName().isEmpty())
- {
- delete top;
- deleted.append(top);
- }
- }
- return totalItems;
-}
-
-/*!
- \internal
- Returns a count of all the items referenced by this node
- and all its children.
-*/
-static int recursiveCount(QGLSceneNode *top)
-{
- int totalItems = 0;
- if (top)
- {
- totalItems = top->count();
- QList<QGLSceneNode*> children = top->children();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for ( ; it != children.constEnd(); ++it)
- totalItems += recursiveCount(*it);
- }
- return totalItems;
-}
-
-static int nodeCount(const QList<QGLSceneNode*> &list)
-{
- int total = 0;
- QList<QGLSceneNode*>::const_iterator it = list.constBegin();
- for ( ; it != list.constEnd(); ++it)
- total += recursiveCount(*it);
- return total;
-}
-
-static inline void warnIgnore(int secCount, QGLSection *s, int vertCount, int nodeCount,
- const char *msg)
-{
- qWarning("Ignoring section %d (%p) with %d vertices and"
- " %d indexes - %s", secCount, s, vertCount, nodeCount, msg);
-}
-
-/*!
- Finish the building of this geometry, optimize it for rendering, and return a
- pointer to the detached top-level scene node (root node).
-
- Since the scene is detached from the builder object, the builder itself
- may be deleted or go out of scope while the scene lives on:
-
- \code
- void MyView::MyView()
- {
- QGLBuilder builder;
- // construct geometry
- m_thing = builder.finalizedSceneNode();
- }
-
- void MyView::~MyView()
- {
- delete m_thing;
- }
-
- void MyView::paintGL()
- {
- m_thing->draw(painter);
- }
- \endcode
-
- The root node will have a child node for each section that was created
- during geometry building.
-
- This method must be called exactly once after building the scene.
-
- \bold{Calling code takes ownership of the scene.} In particular take care
- to either explicitly destroy the scene when it is no longer needed - as shown
- above.
-
- For more complex applications parent each finalized scene node onto a QObject
- so it will be implictly cleaned up by Qt. If you use QGLSceneNode::setParent()
- to do this, you can save an explicit call to addNode() since if setParent()
- detects that the new parent is a QGLSceneNode it will call addNode() for you:
-
- \code
- // here a top level node for the app is created, and parented to the view
- QGLSceneNode *topNode = new QGLSceneNode(this);
-
- QGLBuilder b1;
- // build geometry
-
- QGLSceneNode *thing = b1.finalizedSceneNode();
-
- // does a QObject::setParent() to manage memory, and also adds to the scene
- // graph, so no need to call topNode->addNode(thing)
- thing->setParent(topNode);
-
- QGLBuilder b2;
- // build more geometry
- QGLSceneNode *anotherThing = b2.finalizedSceneNode();
-
- // again parent on get addNode for free
- anotherThing->setParent(topNode);
- \endcode
-
- If this builder is destroyed without calling this method to take
- ownership of the scene, a warning will be printed on the console and the
- scene will be deleted. If this method is called more than once, on the
- second and subsequent calls a warning is printed and NULL is returned.
-
- This function does the following:
- \list
- \o packs all geometry data from sections into QGLSceneNode instances
- \o recalculates QGLSceneNode start() and count() for the scene
- \o deletes all QGLBuilder's internal data structures
- \o returns the top level scene node that references the geometry
- \o sets the internal pointer to the top level scene node to NULL
- \endlist
-
- \sa sceneNode()
-*/
-QGLSceneNode *QGLBuilder::finalizedSceneNode()
-{
- if (dptr->rootNode == 0)
- {
- qWarning("QGLBuilder::finalizedSceneNode() called twice");
- return 0;
- }
- QGeometryData g;
- QMap<quint32, QGeometryData> geos;
- QMap<QGLSection*, int> offsets;
- for (int i = 0; i < dptr->sections.count(); ++i)
- {
- // pack sections that have the same fields into one geometry
- QGLSection *s = dptr->sections.at(i);
- QGL::IndexArray indices = s->indices();
- int icnt = indices.size();
- int ncnt = nodeCount(s->nodes());
- int scnt = s->count();
- if (scnt == 0 || icnt == 0 || ncnt == 0)
- {
- if (!qgetenv("Q_WARN_EMPTY_MESH").isEmpty())
- {
- if (ncnt == 0)
- warnIgnore(scnt, s, icnt, ncnt, "nodes empty");
- else if (scnt == 0)
- warnIgnore(scnt, s, icnt, ncnt, "geometry count zero");
- else
- warnIgnore(scnt, s, icnt, ncnt, "index count zero");
- }
- continue;
- }
- s->normalizeNormals();
- int sectionOffset = 0;
- int sectionIndexOffset = 0;
- if (geos.contains(s->fields()))
- {
- QGeometryData &gd = geos[s->fields()];
- sectionOffset = gd.count();
- sectionIndexOffset = gd.indexCount();
- offsets.insert(s, sectionIndexOffset);
- gd.appendGeometry(*s);
- for (int i = 0; i < icnt; ++i)
- indices[i] += sectionOffset;
- gd.appendIndices(indices);
- }
- else
- {
- g = QGeometryData(*s);
- geos.insert(s->fields(), g);
- }
- }
- while (dptr->sections.count() > 0)
- {
- QGLSection *s = dptr->sections.takeFirst();
- dptr->adjustSectionNodes(s, offsets[s], geos[s->fields()]);
- delete s;
- }
- QGLSceneNode *tmp = dptr->rootNode;
- dptr->rootNode = 0; // indicates root node detached
- return tmp;
-}
-
-/*!
- Creates a new section with smoothing mode set to \a smooth. By default
- \a smooth is QGL::Smooth.
-
- A section must be created before any geometry or new nodes can be added
- to the builder. However one is created automatically by addTriangle()
- and the other add functions; and also by newNode(), pushNode() or popNode()
- if needed.
-
- The internal node stack - see pushNode() and popNode() - is cleared,
- and a new top-level QGLSceneNode is created for this section by calling
- newNode().
-
- \sa newNode(), pushNode()
-*/
-void QGLBuilder::newSection(QGL::Smoothing smooth)
-{
- new QGLSection(this, smooth); // calls addSection
-}
-
-void QGLBuilder::addSection(QGLSection *sec)
-{
- dptr->currentSection = sec;
- sec->setMapThreshold(dptr->defThreshold);
- dptr->sections.append(sec);
- dptr->nodeStack.clear();
- newNode();
-}
-
-/*!
- \internal
- Returns the current section, in which new geometry is being added.
-*/
-QGLSection *QGLBuilder::currentSection() const
-{
- return dptr->currentSection;
-}
-
-/*!
- \internal
- Returns a list of the sections of the geometry in this builder.
-*/
-QList<QGLSection*> QGLBuilder::sections() const
-{
- return dptr->sections;
-}
-
-/*!
- \internal
- Test function only.
-*/
-void QGLBuilder::setDefaultThreshold(int t)
-{
- dptr->defThreshold = t;
-}
-
-/*!
- Returns the root scene node of the geometry created by this builder.
-
- \sa newNode(), newSection()
-*/
-QGLSceneNode *QGLBuilder::sceneNode()
-{
- return dptr->rootNode;
-}
-
-/*!
- Creates a new QGLSceneNode and makes it current. A pointer to the new
- node is returned. The node is added into the scene at the same level
- as the currentNode().
-
- The node is set to reference the geometry starting from the next
- vertex created, such that currentNode()->start() will return the
- index of this next vertex.
-
- \sa newSection()
-*/
-QGLSceneNode *QGLBuilder::newNode()
-{
- if (dptr->currentSection == 0)
- {
- newSection(); // calls newNode()
- return dptr->currentNode;
- }
- QGLSceneNode *parentNode = dptr->rootNode;
- if (dptr->nodeStack.count() > 0)
- parentNode = dptr->nodeStack.last();
- dptr->currentNode = new QGLSceneNode(parentNode);
- dptr->currentNode->setPalette(parentNode->palette());
- dptr->currentNode->setStart(dptr->currentSection->indexCount());
- if (dptr->nodeStack.count() == 0)
- dptr->currentSection->addNode(dptr->currentNode);
- return dptr->currentNode;
-}
-
-/*!
- Returns a pointer to the current scene node, within the current section.
-
- If there is no current section then newSection() will be called to
- create one.
-
- \sa newNode(), newSection()
-*/
-QGLSceneNode *QGLBuilder::currentNode()
-{
- if (dptr->currentSection == 0)
- newSection(); // calls newNode()
- return dptr->currentNode;
-}
-
-/*!
- Creates a new scene node that is a child of the current node and,
- makes it the current node. A pointer to the new node is returned.
- The previous current node is saved on a stack and it may
- be made current again by calling popNode().
-
- \sa popNode(), newNode()
-*/
-QGLSceneNode *QGLBuilder::pushNode()
-{
- if (dptr->currentSection == 0)
- newSection(); // calls newNode()
- QGLSceneNode *parentNode = dptr->currentNode;
- dptr->nodeStack.append(parentNode);
- dptr->currentNode = new QGLSceneNode(parentNode);
- dptr->currentNode->setStart(dptr->currentSection->indexCount());
- dptr->currentNode->setPalette(parentNode->palette());
- return dptr->currentNode;
-}
-
-/*!
- Removes the node from the top of the stack, makes a copy of it, and
- makes the copy current.
-
- If the stack is empty, behaviour is undefined. In debug mode, calling
- this function when the stack is empty will cause an assert.
-
- A pointer to the new current node is returned.
-
- The node is set to reference the geometry starting from the next
- vertex created, such that QGLSceneNode::start() will return the
- index of this next vertex.
-
- \sa pushNode(), newNode()
-*/
-QGLSceneNode *QGLBuilder::popNode()
-{
- if (dptr->currentSection == 0)
- newSection(); // calls newNode()
- int cnt = dptr->currentSection->indexCount();
- QGLSceneNode *s = dptr->nodeStack.takeLast(); // assert here
- QGLSceneNode *parentNode = dptr->rootNode;
- if (dptr->nodeStack.count() > 0)
- parentNode = dptr->nodeStack.last();
- dptr->currentNode = s->cloneNoChildren(parentNode);
- dptr->currentNode->setStart(cnt);
- dptr->currentNode->setCount(0);
- dptr->currentNode->setPalette(parentNode->palette());
- if (dptr->nodeStack.count() == 0)
- dptr->currentSection->addNode(dptr->currentNode);
- return dptr->currentNode;
-}
-
-/*!
- Returns the palette for this builder. This is the QGLMaterialCollection
- pointer that was passed to the constructor; or if that was null a new
- QGLMaterialCollection. This function returns the same result as
- \c{sceneNode()->palette()}.
-
- \sa sceneNode()
-*/
-QGLMaterialCollection *QGLBuilder::palette()
-{
- return dptr->rootNode->palette();
-}
-
-/*!
- \relates QGLBuilder
- Convenience operator for creating a new section in \a builder with \a smoothing.
-
- \code
- // equivalent to builder.newSection(QGL::Faceted)
- builder << QGL::Faceted;
- \endcode
-*/
-QGLBuilder& operator<<(QGLBuilder& builder, const QGL::Smoothing& smoothing)
-{
- builder.newSection(smoothing);
- return builder;
-}
-
-/*!
- \relates QGLBuilder
- Convenience operator for adding \a triangles to the \a builder.
-
- \code
- // equivalent to builder.addTriangles(triangles);
- builder << triangles;
- \endcode
-*/
-QGLBuilder& operator<<(QGLBuilder& builder, const QGeometryData& triangles)
-{
- builder.addTriangles(triangles);
- return builder;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglbuilder.h b/src/threed/geometry/qglbuilder.h
deleted file mode 100644
index 31382e36..00000000
--- a/src/threed/geometry/qglbuilder.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLBuilder_H
-#define QGLBuilder_H
-
-#include <QtCore/qvector.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qvector3d.h>
-#include <QtOpenGL/qgl.h>
-
-#include "qglnamespace.h"
-#include "qglscenenode.h"
-#include "qglattributevalue.h"
-#include "qgeometrydata.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSection;
-class QGLMaterialCollection;
-class QGLBuilderPrivate;
-class QGLPainter;
-
-class Q_QT3D_EXPORT QGLBuilder
-{
-public:
- explicit QGLBuilder(QGLMaterialCollection *materials = 0);
- virtual ~QGLBuilder();
-
- // section management
- void newSection(QGL::Smoothing sm = QGL::Smooth);
-
- // scene management
- QGLSceneNode *sceneNode();
- QGLSceneNode *currentNode();
- QGLSceneNode *newNode();
- QGLSceneNode *pushNode();
- QGLSceneNode *popNode();
- QGLMaterialCollection *palette();
- QGLSceneNode *finalizedSceneNode();
-
- // geometry building by primitive
- void addTriangles(const QGeometryData &triangle);
- void addQuads(const QGeometryData &quad);
- void addTriangleFan(const QGeometryData &fan);
- void addTriangleStrip(const QGeometryData &strip);
- void addTriangulatedFace(const QGeometryData &face);
- void addQuadStrip(const QGeometryData &strip);
- void addQuadsInterleaved(const QGeometryData &top,
- const QGeometryData &bottom);
- inline void addPane(qreal size = 1.0f);
- inline void addPane(QSizeF size);
-
-protected:
- // internal and test functions
- QGLSection *currentSection() const;
- QList<QGLSection*> sections() const;
- void setDefaultThreshold(int);
-
-private:
- Q_DISABLE_COPY(QGLBuilder);
- void addSection(QGLSection *section);
-
- friend class QGLSection;
-
- QGLBuilderPrivate *dptr;
-};
-
-inline void QGLBuilder::addPane(qreal size)
-{
- addPane(QSizeF(size, size));
-}
-
-inline void QGLBuilder::addPane(QSizeF size)
-{
- QSizeF f = size / 2.0f;
- QVector2D a(-f.width(), -f.height());
- QVector2D b(f.width(), -f.height());
- QVector2D c(f.width(), f.height());
- QVector2D d(-f.width(), f.height());
- QVector2D ta(0.0f, 0.0f);
- QVector2D tb(1.0f, 0.0f);
- QVector2D tc(1.0f, 1.0f);
- QVector2D td(0.0f, 1.0f);
- QGeometryData quad;
- quad.appendVertex(a, b, c, d);
- quad.appendTexCoord(ta, tb, tc, td);
- addQuads(quad);
-}
-
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGL::Smoothing& smoothing);
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGeometryData& triangles);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLBuilder_H
diff --git a/src/threed/geometry/qglbuilder_p.h b/src/threed/geometry/qglbuilder_p.h
deleted file mode 100644
index 237f7219..00000000
--- a/src/threed/geometry/qglbuilder_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLBuilder_P_H
-#define QGLBuilder_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.
-//
-
-#include "qglbuilder.h"
-
-#include <QtCore/qmap.h>
-#include <QPointer>
-
-QT_BEGIN_NAMESPACE
-
-class QGLBuilder;
-class QGLSection;
-class QGeometryData;
-
-class QGLBuilderPrivate
-{
-public:
- QGLBuilderPrivate(QGLBuilder *parent);
- ~QGLBuilderPrivate();
- inline void setDirty(bool dirty = true);
- void addTriangle(int a, int b, int c, const QGeometryData &p, int &count);
- void adjustSectionNodes(QGLSection *sec, int offset, const QGeometryData &geom);
- int adjustNodeTree(QGLSceneNode *top, int offset, const QGeometryData &geom,
- QList<QGLSceneNode*> &deleted);
-
- QList<QGLSection*> sections;
- QGLSection *currentSection;
- QList<QGLSceneNode*> nodeStack;
- QGLSceneNode *currentNode;
- QGLSceneNode *rootNode;
- int defThreshold;
- QGLBuilder *q;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLBuilder_P_H
diff --git a/src/threed/geometry/qglcube.cpp b/src/threed/geometry/qglcube.cpp
deleted file mode 100644
index a1932328..00000000
--- a/src/threed/geometry/qglcube.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcube.h"
-#include "qglbuilder.h"
-#include "qvector3darray.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLCube
- \brief The QGLCube class represents the geometry of simple six-sided cube in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The following example adds a cube of 2 units on a side to a
- geometry builder, and draws it at (10, 25, 0) in a QGLPainter:
-
- \code
- QGLBuilder list;
- list.newSection(QGL::Faceted);
- list << QGLCube(2);
- painter->translate(10, 25, 0);
- list.draw(painter);
- \endcode
-
- QGLCube will create a default set of texture coordinates that shows
- the same texture of all six faces.
-*/
-
-/*!
- \fn QGLCube::QGLCube(qreal size)
-
- Constructs the geometry for a regular cube of \a size
- units on a side.
-*/
-
-/*!
- \fn qreal QGLCube::size() const
-
- Returns the size of this cube.
-
- \sa setSize()
-*/
-
-/*!
- \fn void QGLCube::setSize(qreal size)
-
- Sets the \a size of this cube.
-
- \sa size()
-*/
-
-static const int vertexDataLen = 6 * 4 * 3;
-
-static const float vertexData[vertexDataLen] = {
- // +X
- 0.5f, 0.5f, -0.5f,
- 0.5f, 0.5f, 0.5f,
- 0.5f, -0.5f, 0.5f,
- 0.5f, -0.5f, -0.5f,
- // -X
- -0.5f, -0.5f, -0.5f,
- -0.5f, -0.5f, 0.5f,
- -0.5f, 0.5f, 0.5f,
- -0.5f, 0.5f, -0.5f,
-
- // +Y
- -0.5f, 0.5f, -0.5f,
- -0.5f, 0.5f, 0.5f,
- 0.5f, 0.5f, 0.5f,
- 0.5f, 0.5f, -0.5f,
- // -Y
- 0.5f, -0.5f, -0.5f,
- 0.5f, -0.5f, 0.5f,
- -0.5f, -0.5f, 0.5f,
- -0.5f, -0.5f, -0.5f,
-
- // +Z
- 0.5f, -0.5f, 0.5f,
- 0.5f, 0.5f, 0.5f,
- -0.5f, 0.5f, 0.5f,
- -0.5f, -0.5f, 0.5f,
- // -Z
- 0.5f, 0.5f, -0.5f,
- 0.5f, -0.5f, -0.5f,
- -0.5f, -0.5f, -0.5f,
- -0.5f, 0.5f, -0.5f
-};
-
-static const int texCoordDataLen = 6 * 4 * 2;
-
-static const float texCoordData[texCoordDataLen] = {
- // +X
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- // -X
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
-
- // +Y
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
- // -Y
- 1.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
-
- // +Z
- 1.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- // -Z
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
-};
-
-/*!
- \relates QGLCube
-
- Builds the geometry for \a cube within the specified
- geometry \a builder.
-
- This operator specifies the positions, and 2D texture
- co-ordinates for all of the vertices that make up the cube.
- Normals will be calculated by the \a builder, depending on its
- current section's smoothing setting.
-*/
-QGLBuilder& operator<<(QGLBuilder& builder, const QGLCube& cube)
-{
- QGeometryData op;
-
- QVector3DArray vrts = QVector3DArray::fromRawData(
- reinterpret_cast<const QVector3D *>(vertexData), vertexDataLen / 3);
- if (cube.size() != 1.0f)
- vrts.scale(cube.size());
-
- op.appendVertexArray(vrts);
-
- QVector2DArray texx = QVector2DArray::fromRawData(
- reinterpret_cast<const QVector2D *>(texCoordData), texCoordDataLen / 2);
-
- op.appendTexCoordArray(texx);
-
- builder.addQuads(op);
- return builder;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglcube.h b/src/threed/geometry/qglcube.h
deleted file mode 100644
index f9914a04..00000000
--- a/src/threed/geometry/qglcube.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCUBE_H
-#define QGLCUBE_H
-
-#include "qt3dglobal.h"
-
-#include <QtGui/qvector2d.h>
-#include "qvector2darray.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLBuilder;
-
-class Q_QT3D_EXPORT QGLCube
-{
-public:
- explicit QGLCube(qreal size = 1.0f) : m_size(size) {}
-
- qreal size() const { return m_size; }
- void setSize(qreal size) { m_size = size; }
-
-private:
- qreal m_size;
-};
-
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGLCube& cube);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/qglcylinder.cpp b/src/threed/geometry/qglcylinder.cpp
deleted file mode 100644
index 76f5fc75..00000000
--- a/src/threed/geometry/qglcylinder.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcylinder.h"
-#include "qglbuilder.h"
-#include "qvector2darray.h"
-#include "qvector3darray.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLCylinder
- \brief The QGLCylinder class represents the geometry of a simple cylinder/cone in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The following example creates a cone with a top diameter of 1 unit,
- a bottom diameter of of 2 units in diameter and height of 3 units.
-
- It then draws it at (10, 25, 0) in a QGLPainter:
-
- \code
- QGLBuilder builder;
- builder << QGLCylinder(1.0,2.0,3.0);
- QGLSceneNode *node = builder.finalizedSceneNode();
-
- // view the cylinder structure during development
- qDumpScene(node);
-
- painter.translate(10, 25, 0);
- node->draw(&painter);
- \endcode
-
- Note that the bottom circle of the cylinder will always be centred at (0,0,0)
- unless otherwise transformed after cylinder creation.
-
- The QGLCylinder class specifies positions, normals and 2D texture
- co-ordinates for all of the vertices that make up the cylinder.
-
- The texture co-ordinates are fixed at construction time. This
- is because constructing the cylinder can involve generating additional
- vertices which need to interpolate the texture co-ordinates of their
- neighboring vertices.
-
- The QGLCylinder is divided into slices and layers. The slices value
- indicate number of triangular sections into which the top and bottom
- circles of the cylinder are broken into. Consequently it also sets the
- number of facets which run the length of the cylinder. More slices
- results in a smoother circumference.
-
- The layers value indicates the number of longitudinal sections the
- cylinder is broken into. Fewer layers means that the side facets of the
- cylinder will be made up of fewer, very long, triangles, while a higher
- number of layers will produce many and smaller triangles. Often it is
- desirable to avoid large triangles as they may cause inefficiencies in
- texturing/lighting on certain platforms.
-
- The end-caps and sides of the cylinder are independent sections of the
- scene-graph, and so may be textured separately.
-
- Textures are wrapped around the sides of thecylinder in such a way that
- the texture may distort across the x axis if the top and bottom diameters
- of the cylinder differ (ie. the cylinder forms a truncated cone). Textures
- begin and end at the centre points of the top and bottom end-caps of the
- cylinder. This wrapping means that textures on either end-cap may be
- distorted.
-
- Texture coordinates are assigned as shown below.
-
- \image cylinder-texture-coords.png
-
- It is worth noting that the cylinder class can, in fact, be used to generate
- any regular solid polygonal prism. A rectangular prism can be created, for
- example, by creating a 4 sided cylinder. Likewise a hexagonal prism is
- simply a 6 sided cylinder.
-
- With this knowledge, and an understanding of the texture coordinate mapping,
- it is possible to make custom textures which will be usable with these
- three dimensional objects.
-
- \section1 Cylinder Sections and Non-Trivial Scene Structure
-
- When the cylinder is placed in the builder, by necessity separate sections are created
- so that the correct hard edge for the normals is rendered. If there were no
- sections, the smooth shading would try to make the cylinder sides and its flat bases
- all part of a smoothly shaded surface instead of having a sharp crease between them.
-
- Because of this necessary limitation when working with QGLCylinder always examine the
- generate node structure using the qDumpScene() function, as shown above. This will
- display the structure of the generated sections by their named scenenodes,and quickly
- make obvious what required code is needed to render the scene as desired.
-
- In the case of most non-trivial programatically generate geometry, for example
- compiling cubes, cylinders and domes into a single builder, the resulting scene
- will be not organised in a predictable way. Due to the section limitation it is hard
- to avoid the results all being siblings. Using pushNode() does not work because
- section boundaries cause QGLBuilder to reset it's node stack, as the section
- boundaries must be discrete.
-
- \section1 Analysing and Re-organising Scenes
-
- To deal with the structure imposed by separate sections, first use qDumpScene() to
- analyse the scene.
-
- In the simplest case disable the caps of the cylinder so that only one simple node is
- generated, and get a handle to this node via builder.currentNode(). Alternatively
- use seperate builder objects and finalizedSceneNode() calls to obtain distinct
- nodes - these will have Base and Dome sibling objects beneath them.
-
- In extreme cases the tree can have nodes cut out and transplanted onto alternative
- parents like this:
- \code
- // Here root is the builder's root node, either from the
- // sceneNode() function or from finalizedSceneNode():
- QGLSceneNode *dome = new QGLSceneNode;
- dome->setObjectName("Icecream Top");
- QList<QGLSceneNode*> c = root->allChildren();
- for (int i = 0; i < c.size(); ++i)
- {
- if (c.at(i)->objectName() == "Dome" || c.at(i)->objectName() == "Base")
- {
- root->removeNode(c.at(i));
- dome->addNode(c.at(i));
- }
- }
- dome->setPalette(root->palette());
- dome->setMaterialIndex(domeMat);
- \endcode
-
- Note that this code relies on knowledge that the nodes "Dome" and "Base" are created
- and this is obtained via qDumpScene. Using the QGLSceneNode::allChildren() function
- returns a flat list of the heierarchy enabling easy finding of nodes that might be
- deeper in the scene.
-
- Executive summary - use qDumpScene();
-
- \sa QGLBuilder
-*/
-
-
-/*!
- \fn QGLCylinder::QGLCylinder(qreal diameterTop, qreal diameterBase , qreal height, int slices, int layers, bool top, bool base)
-
- Constructs the geometry for a cylinder with top of diameter \a diameterTop,
- a base of diameter \a diameterBase, and a height of \a height.
-
- The resultant mesh will be divided around the vertical axis of the cylinder
- into \a slices individual wedges, and shall be formed of \a layers stacked
- to form the cylinder.
-
- If the values for \a top or \a base are true, then the cylinder will be
- created with solid endcaps. Otherwise, it shall form a hollow pipe.
-
- units on a side.
-*/
-
-
-/*!
- \fn qreal QGLCylinder::diameterTop() const
-
- Returns the diameter of the top of the cylinder.
-
- The default value is 1.
-
- \sa setDiameterTop()
-*/
-
-/*!
- \fn void QGLCylinder::setDiameterTop(qreal diameter)
-
- Sets the diameter of the top of this cylinder to \a diameter.
-
- \sa diameterTop()
-*/
-
-/*!
- \fn qreal QGLCylinder::diameterBottom() const
-
- Returns the diameter of the bottom of the cylinder.
-
- The default value is 1.
-
- \sa setDiameterBottom()
-*/
-
-/*!
- \fn void QGLCylinder::setDiameterBottom(qreal diameter)
-
- Sets the diameter of the bottom of this cylinder to \a diameter.
-
- \sa diameterBottom()
-*/
-
-/*!
- \fn qreal QGLCylinder::height() const
-
- Returns the height of the cylinder.
-
- The default value is 1.0
-
- \sa setDiameterBottom()
-*/
-
-/*!
- \fn void QGLCylinder::setHeight(qreal height)
-
- Sets the height of this cylinder to \a height.
-
- \sa diameterBottom()
-*/
-
-
-/*!
- \fn int QGLCylinder::slices() const
-
- Returns the number of triangular slices the cylinder is divided into
- around its polar axis.
-
- The default is 6.
-
- \sa setSlices()
-*/
-
-/*!
- \fn int QGLCylinder::setSlices(int slices)
-
- Sets the number of triangular \a slices the cylinder is divided into
- around its polar axis.
-
- \sa slices()
-*/
-
-/*!
- \fn int QGLCylinder::layers() const
-
- Returns the number of cylindrical layers the cylinder is divided into
- along its height.
-
- The default is 3.
-
- \sa setLayers()
-*/
-
-/*!
- \fn int QGLCylinder::setLayers(int layers)
-
- Sets the number of stacked \a layers the cylinder is divided into
- along its height.
-
- \sa layers()
-*/
-
-/*!
- \fn bool QGLCylinder::topEnabled() const
-
- Returns true if the top of the cyclinder will be created when
- building the mesh.
-
- The default is true.
-
- \sa setTopEnabled()
-*/
-
-/*!
- \fn void QGLCylinder::setTopEnabled(bool top)
-
- Set whether the top end-cap of the cylinder will be created when
- building the mesh. If \a top is true, the end-cap will be created.
-
- \sa topEnabled()
-*/
-
-/*!
- \fn bool QGLCylinder::baseEnabled() const
-
- Returns true if the base of the cyclinder will be created when
- building the mesh.
-
- The default is true.
-
- \sa setBaseEnabled()
-*/
-
-/*!
- \fn void QGLCylinder::setBaseEnabled(bool base)
-
- Set whether the base end-cap of the cylinder will be created when
- building the mesh. If \a base is true, the end-cap will be created.
-
- \sa baseEnabled()
-*/
-
-/*!
- \relates QGLCylinder
-
- Builds the geometry for \a cylinder within the specified
- geometry \a builder.
-*/
-
-QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder)
-{
- /* ASSERT(cylinder.diameterBottom()>=0 &&
- cylinder.diameterTop()>=0 &&
- cylinder.height()>0);*/
-
- qreal numSlices = qreal(cylinder.slices());
- qreal numLayers = qreal(cylinder.layers());
- qreal topRadius = cylinder.diameterTop()/2.0;
- qreal bottomRadius = cylinder.diameterBottom()/2.0;
-
- qreal angle = 0;
- qreal angleIncrement = (2.0 * M_PI) / numSlices;
- qreal radius = topRadius;
- qreal radiusIncrement = qreal(bottomRadius-topRadius)/ numLayers;
- qreal height = qreal(cylinder.height());
- qreal heightDecrement = height/numLayers;
-
- qreal textureHeight = 1.0;
- qreal textureDecrement = 1.0/numLayers;
-
- QGeometryData oldLayer;
-
- //Generate vertices for the next layer of cylinder
- for (int layerCount=0; layerCount<=cylinder.layers(); layerCount++) {
- QGeometryData newLayer;
-
- //Generate a circle of vertices for this layer.
- for (int i=0; i<cylinder.slices(); i++)
- {
- newLayer.appendVertex(QVector3D(radius * qCos(angle),
- radius * qSin(angle),
- height));
- angle+=angleIncrement;
- }
- angle = 0;
- // Generate texture coordinates (including an extra seam vertex for textures).
- newLayer.appendVertex(newLayer.vertex(0));
- newLayer.generateTextureCoordinates();
- for (int i = 0; i < newLayer.count(); i++) newLayer.texCoord(i).setY(textureHeight);
-
- //Special cases for top end-cap
- if (layerCount==0 && cylinder.topEnabled()) {
- //Draw end-cap at top
- QGeometryData top;
- builder.newSection();
- builder.currentNode()->setObjectName("Cylinder Top");
- top.appendVertex(newLayer.center());
- top.appendVertexArray(newLayer.vertices());
- //Generate a circle of texture vertices for this layer.
- top.appendTexCoord(QVector2D(0.5,0.5));
-
- for (int i=1; i<top.count(); i++)
- {
- top.appendTexCoord(QVector2D(0.5*qCos(angle)+0.5, 0.5*qSin(angle)+0.5));
- angle+=angleIncrement;
- }
- angle = 0;
- builder.addTriangulatedFace(top);
- }
-
-
- //Add a new cylinder layer to the mesh
- if (layerCount>0)
- {
- //If it's the first section, create a cylinder sides section
- if (layerCount==1) {
- builder.newSection();
- builder.currentNode()->setObjectName("Cylinder Sides");
- }
- builder.addQuadsInterleaved(oldLayer, newLayer);
- }
-
- //Special cases for bottom end-cap
- if (layerCount==cylinder.layers() && cylinder.baseEnabled()) {
- //Draw end-cap at bottom
- QGeometryData base;
- builder.newSection();
- builder.currentNode()->setObjectName("Cylinder Base");
- base.appendVertexArray(newLayer.vertices());
- base.appendVertex(newLayer.center());
- //Generate a circle of texture vertices for this layer.
- for (int i=1; i<base.count(); i++)
- {
- base.appendTexCoord(QVector2D(0.5*qCos(angle)+0.5, 0.5*qSin(angle)+0.5));
- angle+=angleIncrement;
- }
- base.appendTexCoord(QVector2D(0.5,0.5));
- angle = 0;
-
- //we need to reverse the above to draw it properly - windings!
- builder.addTriangulatedFace(base.reversed());
- }
-
- //Keep the current layer for drawing the next segment of the cylinder
- oldLayer.clear();
- oldLayer.appendGeometry(newLayer);
- radius+=radiusIncrement;
- height-=heightDecrement;
- textureHeight-=textureDecrement;
- }
-
- return builder;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglcylinder.h b/src/threed/geometry/qglcylinder.h
deleted file mode 100644
index a33adba2..00000000
--- a/src/threed/geometry/qglcylinder.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCYLINDER_H
-#define QGLCYLINDER_H
-
-#include "qt3dglobal.h"
-#include "qglmaterialcollection.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLBuilder;
-class QVector2D;
-
-class Q_QT3D_EXPORT QGLCylinder
-{
-public:
- explicit QGLCylinder(qreal diameterTop = 1.0f, qreal diameterBase = 1.0f, qreal height = 1.0f, int slices = 6, int layers = 3, bool top = true, bool base = true)
- : m_diameterTop(diameterTop), m_diameterBottom(diameterBase), m_height(height), m_slices(slices), m_layers(layers), m_top(top), m_base(base) {}
-
- //Cylinder dimensions
- qreal diameterTop() const {return m_diameterTop;}
- void setDiameterTop(qreal diameter) {m_diameterTop=diameter;}
-
- qreal diameterBottom() const {return m_diameterBottom;}
- void setDiameterBottom(qreal diameter) {m_diameterBottom=diameter;}
-
- qreal height() const {return m_height;}
- void setHeight(qreal height) {m_height = height;}
-
- //Cylinder geometrical subdivisions
- int slices() const {return m_slices;}
- void setSlices(int slices) {m_slices = slices;}
-
- int layers() const {return m_layers;}
- void setLayers(int layers) {m_layers = layers;}
-
- //End-caps attached?
- bool topEnabled() const {return m_top;}
- void setTopEnabled(bool top) {m_top = top;}
-
- bool baseEnabled() const {return m_base;}
- void setBaseEnabled(bool base) {m_base = base;}
-
-protected:
- qreal m_diameterTop;
- qreal m_diameterBottom;
- qreal m_height;
-
- int m_slices;
- int m_layers;
-
- bool m_top;
- bool m_base;
-};
-
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGLCylinder& cylinder);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLCYLINDER_H
diff --git a/src/threed/geometry/qgldome.cpp b/src/threed/geometry/qgldome.cpp
deleted file mode 100644
index ffdd5626..00000000
--- a/src/threed/geometry/qgldome.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgldome.h"
-#include "qglbuilder.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLDome
- \brief The QGLDome class represents the geometry of a simple hemisphere in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The following example creates a dome of 2 units in diameter and
- draws it at (10, 25, 0) in a QGLPainter:
-
- \code
- QGLBuilder builder;
- builder << QGLDome(2);
- QGLSceneNode *node = builder.finalizedSceneNode();
-
- // view the dome structure during development
- qDumpScene(node);
-
- painter.translate(10, 25, 0);
- node->draw(&painter);
- \endcode
-
- The QGLDome class specifies positions, normals and 2D texture
- co-ordinates for all of the vertices that make up the sphere.
-
- The texture co-ordinates are fixed at construction time. This
- is because constructing the sphere can involve generating additional
- vertices which need to interpolate the texture co-ordinates of their
- neighboring vertices.
-
- The default mode of QGLDome is half of a "UV sphere", which divides
- the object up into longitudinal and latitudinal sections. The longitudinal
- slices meet at the pole, which in a single unit dome is defined to
- be at (0, 0, +0.5) and (0, 0, -0.5). This choice is the simplest to
- texture map as the texture will only distort along the x-axis of the
- 2D texture. However the density of vertices is significantly higher at
- the poles than it is elsewhere on the sphere and is a poor choice if a
- uniform density of pixels from the texture map is required.
-
- \section1 Dome Sections and Non-Trivial Scene Structure
-
- When the dome is placed in the builder, by necessity separate sections are created
- so that the correct hard edge for the normals is rendered. If there were no
- sections, the smooth shading would try to make the dome surface and its flat base
- all part of a smoothly shaded surface instead of having a sharp crease between them.
-
- Because of this necessary limitation when working with QGLDome always examine the
- generate node structure using the qDumpScene() function, as shown above. This will
- display the structure of the generated sections by their named scenenodes,and quickly
- make obvious what required code is needed to render the scene as desired.
-
- In the simplest case disable the base of the dome so that only one simple node is
- generated, and get a handle to this node via builder.currentNode(). Alternatively
- use seperate builder objects and finalizedSceneNode() calls to obtain distinct
- nodes - these will have Base and Dome sibling objects beneath them.
-
- For other options see \l{QGLCylinder#analysing-and-re-organising-scenes}{Analysing and Re-organising Scenes} in the QGLCylinder class
- documentation.
-
- Executive summary - use qDumpScene();
-
- \sa QGLBuilder, QGLCylinder
-*/
-
-/*!
- \fn QGLDome::QGLDome(qreal diameter, int depth, bool base)
-
- Creates a dome of \a diameter across (default is 1). When the dome
- is recursively subdivided into triangles, it will be subdivided no more
- than \a depth times (between 1 and 5, default is 3).
-
- If \a base is true, the dome will be drawn with a bottom circle, creating
- an enclosed solid.
-*/
-
-/*!
- Destroys this dome object.
-*/
-QGLDome::~QGLDome()
-{
-}
-
-/*!
- \fn qreal QGLDome::diameter() const
-
- Returns the diameter of this dome. The default is 1.
-
- \sa setDiameter()
-*/
-
-/*!
- \fn void QGLDome::setDiameter(qreal diameter)
-
- Sets the diameter of this dome to \a diameter.
-
- \sa diameter()
-*/
-
-/*!
- \fn int QGLDome::subdivisionDepth() const
-
- Returns the maximum depth when this hemisphere is subdivided into
- triangles. The default is 3. The following picture shows the effect
- of depth values between 1 and 5 for a UV sphere (hemisphere subdivision
- depth shares this scheme).
-
- \image sphere-detail.png
-
- \sa setSubdivisionDepth(), QGLSphere::subdivisionDepth()
-*/
-
-/*!
- \fn void QGLDome::setSubdivisionDepth(int depth)
-
- Sets the maximum \a depth when this hemisphere is subdivided into triangles.
-
- \sa subdivisionDepth()
-*/
-
-/*!
- \fn bool QGLDome::baseEnabled() const
-
- Returns true if the base of the dome will be created when
- building the mesh.
-
- The default is true.
-
- \sa setBaseEnabled()
-*/
-
-/*!
- \fn void QGLDome::setBaseEnabled(bool base)
-
- Set whether the bottom of the dome will be created when
- building the mesh. If \a base is true, the end-cap will be
- created.
-
- \sa baseEnabled()
-*/
-
-/*!
- \relates QGLDome
-
- Builds the geometry for \a dome within the specified
- geometry \a builder.
-*/
-QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome)
-{
- qreal radius = dome.diameter() / 2.0f;
-
- // Determine the number of slices and stacks to generate.
- int divisions = dome.subdivisionDepth();
- if (divisions < 1)
- divisions = 1;
- else if (divisions > 5)
- divisions = 5;
- int stacks = 2 * (1 << divisions);
- int slices = 2 * stacks;
- stacks = stacks>>1;
-
- // Precompute sin/cos values for the slices and stacks.
- const int maxSlices = 4 * (1 << 5) + 1;
- const int maxStacks = 2 * (1 << 5) + 1;
- qreal sliceSin[maxSlices];
- qreal sliceCos[maxSlices];
- qreal stackSin[maxStacks];
- qreal stackCos[maxStacks];
- for (int slice = 0; slice < slices; ++slice) {
- qreal angle = 2 * M_PI * slice / slices;
- sliceSin[slice] = qFastSin(angle);
- sliceCos[slice] = qFastCos(angle);
- }
- sliceSin[slices] = sliceSin[0]; // Join first and last slice.
- sliceCos[slices] = sliceCos[0];
-
- const qreal halfPi=M_PI/2.0;
-
- for (int stack = 0; stack <= stacks; ++stack) {
- qreal angle = halfPi * stack / stacks;
- stackSin[stack] = qFastSin(angle);
- stackCos[stack] = qFastCos(angle);
- }
- stackSin[0] = 0.0f; // Come to a point at the poles.
- stackSin[stacks] = 1.0f;
-
- builder.newSection();
- builder.currentNode()->setObjectName("Dome");
- // Create the stacks for the dome part of the dome
- for (int stack = 0; stack < stacks; ++stack) {
- QGeometryData prim;
- qreal z = radius * stackCos[stack];
- qreal nextz = radius * stackCos[stack + 1];
- qreal s = stackSin[stack];
- qreal nexts = stackSin[stack + 1];
- qreal c = stackCos[stack];
- qreal nextc = stackCos[stack + 1];
- qreal r = radius * s;
- qreal nextr = radius * nexts;
- for (int slice = 0; slice <= slices; ++slice) {
- prim.appendVertex(QVector3D(nextr * sliceSin[slice], nextr * sliceCos[slice], nextz));
- prim.appendNormal(QVector3D(sliceSin[slice] * nexts, sliceCos[slice] * nexts, nextc));
- prim.appendTexCoord(QVector2D(1.0f - qreal(slice) / slices, 1.0f - qreal(stack + 1) / stacks));
-
- prim.appendVertex(QVector3D(r * sliceSin[slice], r * sliceCos[slice], z));
- prim.appendNormal(QVector3D(sliceSin[slice] * s, sliceCos[slice] * s, c));
- prim.appendTexCoord(QVector2D(1.0f - qreal(slice) / slices, 1.0f - qreal(stack) / stacks));
- }
- builder.addQuadStrip(prim);
- }
-
- if (dome.baseEnabled()) {
- //Draw end-cap at bottom
- builder.newSection();
- builder.currentNode()->setObjectName("Base");
-
- //Generate a circle of vertices for this layer.
- QGeometryData tempBase;
-
- tempBase.appendVertex(QVector3D(0,0,0));
- tempBase.appendTexCoord(QVector2D(0.5,0.5));
- for (int slice=0; slice<=slices+1; slice++)
- {
- tempBase.appendVertex(QVector3D(radius * sliceCos[slice], radius * sliceSin[slice], 0));
- tempBase.appendTexCoord(QVector2D(0.5*sliceCos[slice]+0.5, 0.5*sliceSin[slice]+0.5));
- }
-
- //we need to reverse the above to draw it properly - windings!
- builder.addTriangulatedFace(tempBase.reversed());
- }
- return builder;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/threed/geometry/qgldome.h b/src/threed/geometry/qgldome.h
deleted file mode 100644
index 3f3ea3eb..00000000
--- a/src/threed/geometry/qgldome.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLDOME_H
-#define QGLDOME_H
-
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLBuilder;
-
-class Q_QT3D_EXPORT QGLDome
-{
-public:
- explicit QGLDome(qreal diameter = 1.0f, int depth = 3, bool baseEnabled = true)
- : m_diameter(diameter), m_subdivisionDepth(depth), m_baseEnabled(baseEnabled) {}
- virtual ~QGLDome();
-
- qreal diameter() const { return m_diameter; }
- void setDiameter(qreal diameter) { m_diameter = diameter; }
-
- int subdivisionDepth() const { return m_subdivisionDepth; }
- void setSubdivisionDepth(int depth) { m_subdivisionDepth = depth; }
-
- bool baseEnabled() const {return m_baseEnabled; }
- void setBaseEnabled(bool baseEnabled) {m_baseEnabled = baseEnabled;}
-
-private:
- qreal m_diameter;
- int m_subdivisionDepth;
- bool m_baseEnabled;
-};
-
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGLDome& dome);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/qglmaterialcollection.cpp b/src/threed/geometry/qglmaterialcollection.cpp
deleted file mode 100644
index 0f396837..00000000
--- a/src/threed/geometry/qglmaterialcollection.cpp
+++ /dev/null
@@ -1,417 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglmaterialcollection.h"
-#include "qglmaterial_p.h"
-#include <QtCore/qlist.h>
-#include <QtCore/qhash.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLMaterialCollection
- \brief The QGLMaterialCollection class manages groups of materials.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::enablers
-
- Managing more complex 3d graphics with several materials is easier when the
- materials can be referred to as a collection. This is the role of the
- QGLMaterialCollection class.
-
- Plug-ins implementing 3D formats may make the materials defined in
- the format available to the application via a QGLMaterialCollection.
-
- The collection is also optimised for the case where many small objects
- must refer to materials - such as faces in a mesh, or particles. In
- this case the materials can be specified as a short data type using an
- offset into the collection, rather than the material name.
-
- When building up a collection, meshes that refer to the various materials
- can check off which ones are used by calling markMaterialAsUsed(), and then
- remove spurious unused materials by calling removeUnusedMaterials(). This
- technique is suitable for models loaded from a model file where a large
- number of materials may be specified but only a few of those materials
- are used by the particular mesh selected from the scene.
-
- To make a material available from a collection, call addMaterial(). To
- retrieve a material from the collection call removeMaterial().
-
- The collection takes ownership of the QGLMaterial
- objects passed to it by the addMaterial() function. These
- objects will be destroyed when the collection is destroyed.
-*/
-
-class QGLMaterialCollectionPrivate
-{
-public:
- QGLMaterialCollectionPrivate()
- {
- }
-
- QList<QGLMaterial *> materials;
- QHash<QString, int> materialNames;
-};
-
-/*!
- Construct a new empty QGLMaterialCollection object. The \a parent
- is set as the parent of this object.
-*/
-QGLMaterialCollection::QGLMaterialCollection(QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLMaterialCollectionPrivate)
-{
-}
-
-/*!
- Destroy this collection. All material objects referred to by this
- collection will be destroyed.
-*/
-QGLMaterialCollection::~QGLMaterialCollection()
-{
- // The QGLMaterial QObject's are reparented to the collection
- // when addMaterial() is called, so the QObject destructor
- // will take care of cleaning them up for us.
-}
-
-/*!
- Returns a pointer to the material corresponding to \a index; or null
- if \a index is out of range or the material has been removed.
-
- Here's an example of searching for a material with a given ambient
- \c{color} in the collection \c{materials}:
-
- \code
- for (int colorIndex; colorIndex < materials->size(); ++colorIndex) {
- if (material(colorIndex) &&
- material(colorIndex)->ambientColor() == color)
- break;
- }
- if (colorIndex < materials->size())
- myObject->setMaterial(colorIndex);
- \endcode
-*/
-QGLMaterial *QGLMaterialCollection::material(int index) const
-{
- Q_D(const QGLMaterialCollection);
- return d->materials.value(index, 0);
-}
-
-/*!
- \overload
-
- Returns the material associated with \a name in this collection;
- null if \a name is not present or the material has been removed.
-*/
-QGLMaterial *QGLMaterialCollection::material(const QString &name) const
-{
- Q_D(const QGLMaterialCollection);
- int index = d->materialNames.value(name, -1);
- if (index >= 0)
- return d->materials[index];
- else
- return 0;
-}
-
-/*!
- Returns true if this collection contains \a material; false otherwise.
-
- \sa indexOf()
-*/
-bool QGLMaterialCollection::contains(QGLMaterial *material) const
-{
- return material && material->d_func()->collection == this;
-}
-
-/*!
- \overload
-
- Returns true if this collection contains a material called \a name;
- false otherwise.
-
- \sa indexOf()
-*/
-bool QGLMaterialCollection::contains(const QString &name) const
-{
- Q_D(const QGLMaterialCollection);
- return d->materialNames.contains(name);
-}
-
-/*!
- Returns the index of \a material in this collection; -1 if
- \a material is not present in this collection.
-
- \sa contains()
-*/
-int QGLMaterialCollection::indexOf(QGLMaterial *material) const
-{
- if (material && material->d_func()->collection == this)
- return material->d_func()->index;
- else
- return -1;
-}
-
-/*!
- \overload
-
- Returns the index of the material called \a name in this collection;
- -1 if \a name is not present in this collection.
-
- \sa contains()
-*/
-int QGLMaterialCollection::indexOf(const QString &name) const
-{
- Q_D(const QGLMaterialCollection);
- return d->materialNames.value(name, -1);
-}
-
-/*!
- Returns the name of the material at \a index in this material collection;
- a null QString if \a index is out of range.
-*/
-QString QGLMaterialCollection::materialName(int index) const
-{
- Q_D(const QGLMaterialCollection);
- if (index >= 0 && index < d->materials.count()) {
- QGLMaterial *material = d->materials[index];
- if (material) {
- // Use the name in the private data block just in case the
- // application has modified objectName() since adding.
- return material->d_func()->name;
- }
- }
- return QString();
-}
-
-/*!
- Returns true if the material at \a index in this collection has been
- marked as used by markMaterialAsUsed().
-
- \sa markMaterialAsUsed()
-*/
-bool QGLMaterialCollection::isMaterialUsed(int index) const
-{
- QGLMaterial *mat = material(index);
- if (mat)
- return mat->d_func()->used;
- else
- return false;
-}
-
-/*!
- Flags the material corresponding to the \a index as used. Some model files
- may contain a range of materials, applying to various objects in the scene.
-
- When a particular object is loaded from the file, many of those
- materials may not be used in that object. This wastes space,
- with many spurious materials being stored.
-
- Use this method during model loading or construction to mark off
- materials that have been used. Materials so marked will not
- be removed by removeUnusedMaterials().
-
- \sa removeUnusedMaterials(), isMaterialUsed()
-*/
-void QGLMaterialCollection::markMaterialAsUsed(int index)
-{
- QGLMaterial *mat = material(index);
- if (mat)
- mat->d_func()->used = true;
-}
-
-/*!
- Removes and deletes materials which have not been marked as used.
-
- \sa markMaterialAsUsed(), isMaterialUsed()
-*/
-void QGLMaterialCollection::removeUnusedMaterials()
-{
- Q_D(QGLMaterialCollection);
- for (int index = 0; index < d->materials.size(); ++index) {
- QGLMaterial *material = d->materials[index];
- if (material && !material->d_func()->used)
- delete removeMaterial(index);
- }
-}
-
-/*!
- Adds \a material to this collection and returns its new index. The
- collection takes ownership of the material and will delete it when the
- collection is destroyed. Initially the \a material is marked as unused.
-
- The QObject::objectName() of \a material at the time addMaterial()
- is called will be used as the material's name within this collection.
- Changes to the object name after the material is added are ignored.
-
- If \a material is already present in this collection, then this
- function will return the index that was previously assigned.
-
- Returns -1 if \a material has been added to another collection.
-
- \sa removeMaterial(), markMaterialAsUsed()
-*/
-int QGLMaterialCollection::addMaterial(QGLMaterial *material)
-{
- Q_D(QGLMaterialCollection);
- Q_ASSERT(material);
-
- // Allocate a new index for the material.
- int index = d->materials.count();
-
- // Record the index in the private data attached to the material.
- // This allows us to find the material's index quickly later.
- QGLMaterialPrivate *dm = material->d_func();
- if (dm->collection) {
- if (dm->collection == this)
- return dm->index;
- return -1;
- }
- dm->collection = this;
- dm->index = index;
- dm->name = material->objectName();
- dm->used = false;
-
- // Add the material to this collection.
- material->setParent(this);
- d->materials.append(material);
- if (!dm->name.isEmpty())
- d->materialNames[dm->name] = index;
- connect(material, SIGNAL(destroyed()), this, SLOT(materialDeleted()));
- return index;
-}
-
-/*!
- Removes all instances of \a material from this collection.
- The \a material object is not deleted and can be reused.
-
- Does nothing if \a material is null or not a member of
- this collection.
-
- \sa addMaterial()
-*/
-void QGLMaterialCollection::removeMaterial(QGLMaterial *material)
-{
- Q_D(QGLMaterialCollection);
- if (!material)
- return;
-
- // Check the material's owning collection.
- QGLMaterialPrivate *dm = material->d_func();
- if (dm->collection != this)
- return;
-
- // Remove the material from the collection.
- d->materials[dm->index] = 0;
- if (!dm->name.isEmpty())
- d->materialNames.remove(dm->name);
- material->setParent(0);
-
- // Detach from the owning collection.
- dm->collection = 0;
- dm->index = -1;
-}
-
-/*!
- Removes the material at \a index from this collection, and returns
- a pointer to the material.
-
- Since the collection is designed for fast lookup by index, the
- the stored material pointer is set to null but the \a index
- otherwise remains valid.
-*/
-QGLMaterial *QGLMaterialCollection::removeMaterial(int index)
-{
- Q_D(QGLMaterialCollection);
-
- // Bail out if the material is invalid.
- if (index < 0 || index >= d->materials.count())
- return 0;
- QGLMaterial *material = d->materials[index];
- if (!material)
- return 0;
-
- // Remove the material from the collection.
- QGLMaterialPrivate *dm = material->d_func();
- d->materials[index] = 0;
- if (!dm->name.isEmpty())
- d->materialNames.remove(dm->name);
- material->setParent(0);
-
- // Detach from the owning collection.
- dm->collection = 0;
- dm->index = -1;
- return material;
-}
-
-/*!
- Returns true if this collection is empty, false otherwise.
-
- \sa size()
-*/
-bool QGLMaterialCollection::isEmpty() const
-{
- Q_D(const QGLMaterialCollection);
- return d->materials.isEmpty();
-}
-
-/*!
- Returns the number of (possibly null) materials in this collection.
- Null materials result from calling removeMaterial().
-
- \sa isEmpty()
-*/
-int QGLMaterialCollection::size() const
-{
- Q_D(const QGLMaterialCollection);
- return d->materials.size();
-}
-
-/*!
- \internal
- Responds to the destroyed() signal by calling removeMaterial() on the
- material about to be deleted;
-*/
-void QGLMaterialCollection::materialDeleted()
-{
- removeMaterial(qobject_cast<QGLMaterial *>(sender()));
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglmaterialcollection.h b/src/threed/geometry/qglmaterialcollection.h
deleted file mode 100644
index 0ef8efd1..00000000
--- a/src/threed/geometry/qglmaterialcollection.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLMATERIALCOLLECTION_H
-#define QGLMATERIALCOLLECTION_H
-
-#include <QtCore/qobject.h>
-
-#include "qt3dglobal.h"
-#include "qglmaterial.h"
-#include "qgltexture2d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLMaterialCollectionPrivate;
-
-class Q_QT3D_EXPORT QGLMaterialCollection : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLMaterialCollection)
- Q_DISABLE_COPY(QGLMaterialCollection)
-public:
- QGLMaterialCollection(QObject *parent = 0);
- virtual ~QGLMaterialCollection();
-
- QGLMaterial *material(int index) const;
- QGLMaterial *material(const QString &name) const;
-
- bool contains(QGLMaterial *material) const;
- bool contains(const QString &name) const;
-
- int indexOf(QGLMaterial *material) const;
- int indexOf(const QString &name) const;
-
- QString materialName(int index) const;
-
- bool isMaterialUsed(int index) const;
- void markMaterialAsUsed(int index);
- void removeUnusedMaterials();
-
- int addMaterial(QGLMaterial *material);
- void removeMaterial(QGLMaterial *material);
- QGLMaterial *removeMaterial(int index);
-
- bool isEmpty() const;
- int size() const;
-
-private Q_SLOTS:
- void materialDeleted();
-
-private:
- QScopedPointer<QGLMaterialCollectionPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLMATERIALCOLLECTION_H
diff --git a/src/threed/geometry/qglsection.cpp b/src/threed/geometry/qglsection.cpp
deleted file mode 100644
index f60e9ffc..00000000
--- a/src/threed/geometry/qglsection.cpp
+++ /dev/null
@@ -1,700 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsection_p.h"
-#include "qglbuilder_p.h"
-#include "qarray.h"
-#include "qvector_utils_p.h"
-
-#include <QtGui/qvector3d.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qpointer.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qbitarray.h>
-
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QGLSection
- \brief The QGLSection class clusters like geometry in a QGLBuilder.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- QGLSection instances partition a QGLBuilder into related sections,
- while the builder is being initialized with geometry data.
-
- Once the builder is initialized, and geometry building is complete
- the QGLSection instances are destroyed and the data is uploaded to the
- graphics hardware.
-
- The QGLSection class is a work horse for the QGLBuilder, and it
- takes care of automatically managing vertex data. As such
- for usual use cases, its functionality will not need to be referenced
- directly. For low-level access to geometry, QGLSection provides a
- range of accessors to reference geometry data during scene building.
-
- Within a section, incoming geometry data will be coalesced and
- indexes created to reference the fewest possible copies of the vertex
- data. For example, in smooth geometry all copies of a vertex are
- coalesced into one, and referenced by indices - except in the case
- where texture data forms a \i seam and a copy must be created to carry
- the two texture coordinates of the seam.
-
- This is handled automatically by QGLSection, to pack data into the
- smallest space possible thus improving cache coherence and performance.
-
- All the vertices in a QGLSection are treated with the same
- \l{QGL::Smoothing}{smoothing}, and have the same
- \l{QLogicalVertex::Type}{data types}.
-
- Each QGLSection references a contiguous range of vertices in a
- QGLBuilder.
-
- A QGLBuilder instance has the \l{QGLBuilder::newSection()}{newSection()}
- function which creates a new QGLSection to reference its data. Use this
- to construct new QGLSection instances, or alternatively construct
- a new QGLSection() and pass a non-null QGLBuilder pointer.
-
- These functions all return QVector values. QVector instances are
- implicitly shared, thus the copies are inexpensive unless a
- non-const function is called on them, triggering a copy-on-write.
-
- Generally for adding geometry, use append(). This function simply
- calls virtual protected functions appendSmooth() (for smoothed vertices)
- and appendFaceted() (for faceted vertices). See QGLBuilder for a
- discussion of smoothing.
-*/
-
-// allow QVector3D's to be stored in a QMap
-inline bool operator<(const QVector3D &a, const QVector3D &b)
-{
- if (qFskCompare(a.x(), b.x()))
- {
- if (qFskCompare(a.y(), b.y()))
- {
- if (qFskCompare(a.z(), b.z()))
- {
- return false; // equal so not less-than
- }
- else
- {
- return a.z() < b.z();
- }
- }
- else
- {
- return a.y() < b.y();
- }
- }
- else
- {
- return a.x() < b.x();
- }
-}
-
-static inline bool qSameDirection(const QVector3D &a , const QVector3D &b)
-{
- bool res = false;
- if (!a.isNull() && !b.isNull())
- {
- float dot = QVector3D::dotProduct(a, b);
- res = qFskCompare((qreal)dot, a.length() * b.length());
- }
- return res;
-}
-
-class QGLSectionPrivate
-{
-public:
- QGLSectionPrivate(const QVector3DArray *ary)
- : vec_data(ary)
- , it(vec_map.end())
- , map_threshold(5)
- , number_mapped(0)
- , start_ptr(-1)
- , end_ptr(-1)
- {
- normIndices.fill(-1, 32);
- }
-
- ~QGLSectionPrivate() {}
-
- bool normalAccumulated(int index, const QVector3D &norm) const
- {
- if (index >= normIndices.size())
- return false;
- int ptr = normIndices.at(index);
- while (ptr != -1)
- {
- int val_ptr = normPtrs.at(ptr);
- //if (normValues.at(val_ptr) == norm)
- if (qSameDirection(normValues.at(val_ptr), norm))
- return true;
- ptr = normPtrs.at(ptr+1);
- }
- return false;
- }
-
- void accumulateNormal(int index, const QVector3D &norm)
- {
- int new_norm_index = normValues.size();
- normValues.append(norm);
- if (normIndices.size() <= index)
- {
- int old_size = normIndices.size();
- normIndices.extend(32);
- for (int i = old_size; i < normIndices.size(); ++i)
- normIndices[i] = -1;
- }
- int new_norm_ptr = normPtrs.size();
- normPtrs.append(new_norm_index); // even ptrs point to vector value
- normPtrs.append(-1); // odd ptrs point to next in normPtr linked list
- if (normIndices.at(index) == -1)
- {
- normIndices[index] = new_norm_ptr;
- }
- else
- {
- int norm_ptr = normIndices.at(index);
- while (normPtrs.at(norm_ptr + 1) != -1)
- {
- norm_ptr = normPtrs.at(norm_ptr + 1);
- }
- normPtrs[norm_ptr+1] = new_norm_ptr;
- }
- }
-
- void mapVertex(const QVector3D &v, int ix)
- {
- Q_UNUSED(ix);
- Q_UNUSED(v);
- static bool seeded = false;
- if (!seeded)
- qsrand(31415);
- Q_ASSERT(vec_data->at(ix) == v);
- if ((vec_data->size() - number_mapped) > map_threshold)
- {
- int to_map = vec_data->size() - number_mapped;
- QArray<int, 100> shuffle(to_map, -1);
- for (int i = number_mapped, k = 0; i < vec_data->size(); ++i, ++k)
- shuffle[k] = i;
- for (int n = to_map; n > 1; --n)
- {
- int k = qrand() % n;
- int tmp = shuffle[k];
- shuffle[k] = shuffle[n - 1];
- shuffle[n - 1] = tmp;
- }
- for (int i = 0; i < to_map; ++i)
- vec_map.insertMulti(vec_data->at(shuffle.at(i)), shuffle.at(i));
- number_mapped += to_map;
- }
- }
-
- int nextIndex()
- {
- int result = -1;
- if (end_ptr != -1)
- {
- // first look through the unmapped items
- while (start_ptr <= end_ptr && result == -1)
- {
- // search from the end and beginning, favouring the end - most often
- // its in the last few we added, sometimes in the first ones
- if (qFskCompare(vec_data->at(end_ptr--), target))
- result = end_ptr+1;
- else if (start_ptr <= end_ptr && qFskCompare(vec_data->at(end_ptr--), target))
- result = end_ptr+1;
- else if (start_ptr <= end_ptr && qFskCompare(vec_data->at(start_ptr++), target))
- result = start_ptr-1;
- }
- // if that found nothing, have a look at the map
- if (result == -1)
- {
- start_ptr = -1;
- end_ptr = -1;
- it = vec_map.constEnd();
- if (vec_map.size() > 0)
- it = vec_map.find(target);
- }
- }
- if (it != vec_map.constEnd())
- {
- // if there was something in the map see if its still on target
- if (qFskCompare(it.key(), target))
- {
- result = it.value();
- ++it; // increment to find more insertMulti instances
- }
- else
- {
- // not on target - flag that we're done here
- it = vec_map.constEnd();
- }
- }
- return result;
- }
-
- int findVertex(const QVector3D &v)
- {
- end_ptr = vec_data->size() - 1; // last one not in QMap
- start_ptr = number_mapped; // first one not in QMap
- target = v;
- return nextIndex();
- }
-
- // mapper
- int index;
- QVector3D target;
- const QVector3DArray *vec_data;
- QMap<QVector3D, int> vec_map;
- QMap<int, int> index_map;
- QMap<QVector3D,int>::const_iterator it;
- int map_threshold; // if more than this is unmapped, do a mapping run
- int number_mapped; // how many vertices have been mapped
- int start_ptr;
- int end_ptr;
-
- QArray<int, 32> normIndices;
- QArray<int, 32> normPtrs;
- QArray<QVector3D, 32> normValues;
-
- QList<QGLSceneNode*> nodes;
-};
-
-/*!
- \internal
- Construct a new QGLSection on \a builder, and with smoothing \a s.
- By default the smoothing is QGL::Smooth.
-
- See QGLBuilder for a discussion of smoothing.
-
- The pointer \a list must be non-null, and in debug mode, unless QT_NO_DEBUG is
- defined, this function will assert if \a list is null.
-
- The following lines of code have identical effect:
- \code
- QGLSection *s = myDisplayList->newSection(QGL::Faceted);
- QGLSection *s2 = new QGLSection(myDisplayList, QGL::Faceted);
- \endcode
-*/
-QGLSection::QGLSection(QGLBuilder *builder, QGL::Smoothing s)
- : m_smoothing(s)
- , d(0)
-{
- Q_ASSERT(builder);
- enableField(QGL::Position);
- Q_ASSERT(vertexData());
- d = new QGLSectionPrivate(vertexData());
- builder->addSection(this);
-}
-
-/*!
- \internal
- Destroy this QGLSection, recovering any resources.
-*/
-QGLSection::~QGLSection()
-{
- delete d;
-}
-
-/*!
- \internal
- Reserve capacity for \a amount items. This may avoid realloc
- overhead when a large number of items will be appended.
-*/
-void QGLSection::reserve(int amount)
-{
- QGeometryData::reserve(amount);
- d->normIndices.reserve(amount);
- d->normPtrs.reserve(amount * 2);
- d->normValues.reserve(amount);
-}
-
-/*!
- \internal
- Adds the logical vertices \a a, \a b and \c to this section. All
- should have the same fields. This function is exactly equivalent to
- \code
- append(a); append(b); append(c);
- \endcode
-
- \sa appendSmooth(), appendFaceted()
-*/
-void QGLSection::append(const QLogicalVertex &a, const QLogicalVertex &b, const QLogicalVertex &c)
-{
- Q_ASSERT(a.fields() == b.fields() && b.fields() == c.fields());
- if (!a.hasField(QGL::Normal))
- {
- appendFaceted(a, b, c);
- }
- else
- {
- if (m_smoothing == QGL::Smooth)
- appendSmooth(a, b, c);
- else
- appendFaceted(a, b, c);
- }
-}
-
-/*!
- \internal
- Adds the logical vertex \a lv to this section.
-
- Otherwise, if the \a lv does have a lighting normal; then the
- vertex processing depends on the smoothing property of this section.
- If this section has smoothing QGL::Smooth, then the append will be done
- by calling appendSmooth(); or if this section has smoothing QGL::Faceted,
- then the append will be done by calling appendFaceted().
-
- \sa appendSmooth(), appendFaceted()
-*/
-void QGLSection::append(const QLogicalVertex &lv)
-{
- if (!lv.hasField(QGL::Normal))
- {
- appendFaceted(lv);
- }
- else
- {
- if (m_smoothing == QGL::Smooth)
- appendSmooth(lv);
- else
- appendFaceted(lv);
- }
-}
-
-static bool qCompareByAttributes(const QLogicalVertex &a, const QLogicalVertex &b)
-{
- static const quint32 ATTRS_AND_TEXTURES = (0xFFFFFFFF << QGL::TextureCoord0);
- quint32 af = a.fields() & ATTRS_AND_TEXTURES;
- quint32 bf = b.fields() & ATTRS_AND_TEXTURES;
- if (af != bf)
- return false;
- quint32 flds = af | bf;
- const quint32 mask = 0x01;
- flds >>= QGL::TextureCoord0;
- for (int i = QGL::TextureCoord0; flds; ++i, flds >>= 1)
- {
- if (flds & mask)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(i);
- if (attr < QGL::CustomVertex0)
- {
- if (!qFskCompare(a.texCoord(attr), b.texCoord(attr)))
- return false;
- }
- else
- {
- QVariant v1 = a.attribute(attr);
- QVariant v2 = b.attribute(attr);
- 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));
- else if (v1.type() == QVariant::Vector3D)
- return qFskCompare(qVariantValue<QVector3D>(v1), qVariantValue<QVector3D>(v2));
- else
- return v1 == v2;
- }
- }
- }
- return true;
-}
-
-int QGLSection::appendOne(const QLogicalVertex &lv)
-{
-#ifndef QT_NO_DEBUG_STREAM
- if (count() && lv.fields() != fields())
- {
- qDebug() << "Warning: adding" << lv << "fields:" << lv.fields()
- << "fields do not match existing:" << fields()
- << "create new section first?";
- }
-#endif
- int index = appendVertex(lv);
- d->mapVertex(lv.vertex(), index);
- appendIndex(index);
- return index;
-}
-
-/*!
- \internal
- Adds the logical vertex \a lv to this section of a builder.
-
- Two QLogicalVertex instances a and b are treated as being duplicates for
- the purpose of smoothing, if \c{qFuzzyCompare(a.vertex(), b.vertex())} is
- true
-
- All duplicate occurrences of a vertex are coalesced, that is replaced
- by a GL index referencing the one copy.
-
- In order to draw \a lv as part of a smooth continuous surface, with
- no distinct edge, duplicates of vertex \a lv are coalesced into one
- (within this section) and the normal for that one set to the average of
- the incoming unique normals.
-
- The incoming vertex \a lv is not treated as a duplicate if \a lv has
- different texture coordinates or attributes. This occurs for example
- in the case of a texture seam, where two different texture coordinates
- are required at the same point on the geometry.
-
- In that case a new duplicate vertex is added to carry the unique
- texture coordinates or attributes. When new vertex copies are added in
- this way all copies receive the averaged normals.
-
- Call this function to add the vertices of a smooth face to the section
- of a builder, or use:
-
- \code
- myDisplayList->newSection(QGLBuilder::Smooth);
- myDisplayList->addTriangle(a, b, c);
- \endcode
-
- In smooth surfaces, the vertex and its normal is only sent to the
- graphics hardware once (not once per face), thus smooth geometry may
- consume fewer resources.
-
- \sa appendFaceted(), updateTexCoord(), QGLBuilder::newSection()
-*/
-void QGLSection::appendSmooth(const QLogicalVertex &lv)
-{
- Q_ASSERT(lv.hasField(QGL::Position));
- Q_ASSERT(lv.hasField(QGL::Normal));
-
- int found_index = d->findVertex(lv.vertex());
- bool coalesce = false;
- if (found_index == -1)
- {
- int newIndex = appendOne(lv);
- d->accumulateNormal(newIndex, lv.normal());
- }
- else
- {
- while (!coalesce && found_index != -1)
- {
- if (qCompareByAttributes(lv, logicalVertexAt(found_index)))
- coalesce = true;
- else
- found_index = d->nextIndex();
- }
- if (!coalesce) // texture or attributes prevented coalesce
- {
- // new vert to carry tex/attrib data
- d->accumulateNormal(appendOne(lv), lv.normal());
- }
- else
- {
- appendIndex(found_index);
- while (found_index != -1)
- {
- if (!d->normalAccumulated(found_index, lv.normal()))
- {
- normal(found_index) += lv.normal();
- d->accumulateNormal(found_index, lv.normal());
- }
- found_index = d->nextIndex();
- }
- }
- }
-}
-
-
-void QGLSection::appendSmooth(const QLogicalVertex &lv, int index)
-{
- Q_ASSERT(lv.hasField(QGL::Position));
- Q_ASSERT(lv.hasField(QGL::Normal));
-
- int found_index = -1;
- QMap<int, int>::const_iterator it = d->index_map.constFind(index);
- if (it != d->index_map.constEnd())
- found_index = it.value();
- if (found_index == -1)
- {
- int newIndex = appendVertex(lv);
- d->index_map.insert(index, newIndex);
- appendIndex(newIndex);
- d->accumulateNormal(newIndex, lv.normal());
- }
- else
- {
- appendIndex(found_index);
- if (!d->normalAccumulated(found_index, lv.normal()))
- {
- normal(found_index) += lv.normal();
- d->accumulateNormal(found_index, lv.normal());
- }
- }
-}
-
-/*!
- \internal
- Add the logical vertex \a lv to this section of a builder.
-
- The vertex will be drawn as a distinct edge, instead of just part of a
- continuous smooth surface. To acheive this the vertex value of \a lv
- is duplicated for each unique normal in the current section.
-
- Note that duplication is only for unique normals: if a vertex is already
- present with a given normal it is coalesced and simply referenced by index.
- As for appendSmooth() vertices are not coalesced in this way if \a lv
- has a different texture coordinate or attribute than its duplicate.
-
- In faceted surfaces, the vertex is sent to the graphics hardware once for
- each normal it has, and thus may consume more resources.
-
- \sa appendSmooth(), updateTexCoord(), QGLBuilder::newSection()
-*/
-void QGLSection::appendFaceted(const QLogicalVertex &lv)
-{
- Q_ASSERT(lv.hasField(QGL::Position));
- int found_index = d->findVertex(lv.vertex());
- bool coalesce = false;
- while (!coalesce && found_index != -1)
- {
- if (logicalVertexAt(found_index) == lv)
- coalesce = true;
- else
- found_index = d->nextIndex();
- }
- if (coalesce) // found
- {
- appendIndex(found_index);
- }
- else
- {
- appendOne(lv);
- }
-}
-
-/*!
- \internal
- Returns the current map threshold for this section. The threshold is the
- point at which the section switches from using a plain QArray - with
- linear performance ie O(n) - to using a QMap - with approx O(log n). These
- structures are used for looking up vertices during the index generation and
- normals calculation.
-
- The default value is 50.
-
- \sa setMapThreshold()
-*/
-int QGLSection::mapThreshold() const
-{
- return d->map_threshold;
-}
-
-/*!
- \internal
- Sets the current map threshold to \a t for this section.
-
- \sa mapThreshold()
-*/
-void QGLSection::setMapThreshold(int t)
-{
- d->map_threshold = t;
-}
-
-/*!
- \internal
- Returns a list of the QGLSceneNode instances associated with this section.
-*/
-QList<QGLSceneNode*> QGLSection::nodes() const
-{
- return d->nodes;
-}
-
-/*!
- \internal
- Adds the \a node to the list of QGLSceneNode instances associated with
- this section.
-*/
-void QGLSection::addNode(QGLSceneNode *node)
-{
- d->nodes.append(node);
-}
-
-/*!
- \internal
- Deletes the \a node from the list of QGLSceneNode instances associated
- with this section. Returns true if the \a node was found, false
- otherwise.
-*/
-bool QGLSection::deleteNode(QGLSceneNode *node)
-{
- int ix = d->nodes.indexOf(node);
- if (ix != -1)
- {
- d->nodes.removeAt(ix);
- return true;
- }
- return false;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-/*!
- \internal
- Output a string representation of \a section to a debug stream \a dbg.
- \relates QGLSection
-*/
-QDebug operator<<(QDebug dbg, const QGLSection &section)
-{
- dbg.space()
- << "QGLSection(" << &section
- << "- count:" << section.count()
- << "- smoothing mode:" << (section.smoothing() == QGL::Smooth ?
- "QGL::Smooth" : "QGL::Faceted") << "\n";
- QGL::IndexArray indices = section.indices();
- for (int i = 0; i < section.count(); ++i)
- {
- int ix = indices[i];
- dbg << section.logicalVertexAt(ix) << "\n";
- }
- dbg << ")\n";
- return dbg.space();
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglsection_p.h b/src/threed/geometry/qglsection_p.h
deleted file mode 100644
index 8d6847ac..00000000
--- a/src/threed/geometry/qglsection_p.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSECTION_H
-#define QGLSECTION_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.
-//
-
-#include "qglpainter.h"
-#include "qlogicalvertex.h"
-#include "qbox3d.h"
-#include "qglnamespace.h"
-
-#include <QtOpenGL/qgl.h>
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLPainter;
-class QGLBuilder;
-class QGLSectionPrivate;
-class QGeometryData;
-class QGLSceneNode;
-
-class Q_QT3D_EXPORT QGLSection : public QGeometryData
-{
-public:
- QGLSection(QGLBuilder *d, QGL::Smoothing sm = QGL::Smooth);
- ~QGLSection();
-
- void reserve(int amount);
-
- void append(const QLogicalVertex &lv);
- void append(const QLogicalVertex &a, const QLogicalVertex &b, const QLogicalVertex &c);
- void appendSmooth(const QLogicalVertex &lv);
- void appendSmooth(const QLogicalVertex &lv, int index);
- void appendSmooth(const QLogicalVertex &a, const QLogicalVertex &b, const QLogicalVertex &c)
- {
- appendSmooth(a);
- appendSmooth(b);
- appendSmooth(c);
- }
- void appendFaceted(const QLogicalVertex &lv);
- void appendFaceted(const QLogicalVertex &a, const QLogicalVertex &b, const QLogicalVertex &c)
- {
- appendFaceted(a);
- appendFaceted(b);
- appendFaceted(c);
- }
-
- inline QGL::Smoothing smoothing() const;
- inline void setSmoothing(QGL::Smoothing s);
- int mapThreshold() const;
- void setMapThreshold(int);
- QList<QGLSceneNode*> nodes() const;
- void addNode(QGLSceneNode *node);
- bool deleteNode(QGLSceneNode *node);
-private:
- Q_DISABLE_COPY(QGLSection);
- friend class QGLBuilder;
-
- int appendOne(const QLogicalVertex &vertex);
-
- QGL::Smoothing m_smoothing;
- QGLSectionPrivate *d;
-};
-
-inline QGL::Smoothing QGLSection::smoothing() const
-{
- return m_smoothing;
-}
-
-inline void QGLSection::setSmoothing(QGL::Smoothing s)
-{
- m_smoothing = s;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QGLSection &section);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QGLSECTION_H
diff --git a/src/threed/geometry/qglsphere.cpp b/src/threed/geometry/qglsphere.cpp
deleted file mode 100644
index f3b3856b..00000000
--- a/src/threed/geometry/qglsphere.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsphere.h"
-#include "qglbuilder.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLSphere
- \brief The QGLSphere class represents the geometry of a simple sphere in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The following example creates a sphere of 2 units in diameter and
- draws it at (10, 25, 0) in a QGLPainter:
-
- \code
- QGLBuilder builder;
- builder << QGLSphere(2);
- QGLSceneNode *node = builder.finalizedSceneNode();
-
- painter.translate(10, 25, 0);
- node->draw(&painter);
- \endcode
-
- The QGLSphere class specifies positions, normals and 2D texture
- co-ordinates for all of the vertices that make up the sphere.
-
- The texture co-ordinates are fixed at construction time. This
- is because constructing the sphere can involve generating additional
- vertices which need to interpolate the texture co-ordinates of their
- neighboring vertices.
-
- The default mode of QGLSphere is a "UV sphere", which divides the
- sphere up into longitudinal and latitudinal sections. The longitudinal
- slices meet at the poles, which in a single unit sphere are defined to
- be at (0, 0, +0.5) and (0, 0, -0.5). This choice is the simplest to
- texture map as the texture will only distort along the x-axis of the
- 2D texture. However the density of vertices is significantly higher at
- the poles than it is elsewhere on the sphere and is a poor choice if a
- uniform density of pixels from the texture map is required.
-
- \sa QGLBuilder
-*/
-
-/*!
- \fn QGLSphere::QGLSphere(qreal diameter, int depth)
-
- Creates a sphere of \a diameter across (default is 1). When the sphere
- is recursively subdivided into triangles, it will be subdivided no more
- than \a depth times (between 1 and 10, default is 5).
-*/
-
-/*!
- Destroys this sphere object.
-*/
-QGLSphere::~QGLSphere()
-{
-}
-
-/*!
- \fn qreal QGLSphere::diameter() const
-
- Returns the diameter of this sphere. The default is 1.
-
- \sa setDiameter()
-*/
-
-/*!
- \fn void QGLSphere::setDiameter(qreal diameter)
-
- Sets the diameter of this sphere to \a diameter.
-
- \sa diameter()
-*/
-
-/*!
- \fn int QGLSphere::subdivisionDepth() const
-
- Returns the maximum depth when this sphere is subdivided into triangles.
- The default is 5. The following picture shows the effect of depth
- values between 1 and 10 for a UV sphere:
-
- \image sphere-detail.png
-
- \table
- \header \o Level of Detail \o Number of Triangles
- \row \o 1 \o 64
- \row \o 2 \o 128
- \row \o 3 \o 256
- \row \o 4 \o 512
- \row \o 5 \o 1024
- \row \o 6 \o 2048
- \row \o 7 \o 4096
- \row \o 8 \o 8192
- \row \o 9 \o 16384
- \row \o 10 \o 32768
- \endtable
-
- \sa setSubdivisionDepth()
-*/
-
-/*!
- \fn void QGLSphere::setSubdivisionDepth(int depth)
-
- Sets the maximum \a depth when this sphere is subdivided into triangles.
-
- \sa subdivisionDepth()
-*/
-
-/*!
- \relates QGLSphere
-
- Builds the geometry for \a sphere within the specified
- geometry \a builder.
-*/
-QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere)
-{
- qreal radius = sphere.diameter() / 2.0f;
-
- // Determine the number of slices and stacks to generate.
- static int const slicesAndStacks[] = {
- 8, 4,
- 8, 8,
- 16, 8,
- 16, 16,
- 32, 16,
- 32, 32,
- 64, 32,
- 64, 64,
- 128, 64,
- 128, 128
- };
- int divisions = sphere.subdivisionDepth();
- if (divisions < 1)
- divisions = 1;
- else if (divisions > 10)
- divisions = 10;
- int stacks = slicesAndStacks[divisions * 2 - 1];
- int slices = slicesAndStacks[divisions * 2 - 2];
-
- // Precompute sin/cos values for the slices and stacks.
- const int maxSlices = 128 + 1;
- const int maxStacks = 128 + 1;
- qreal sliceSin[maxSlices];
- qreal sliceCos[maxSlices];
- qreal stackSin[maxStacks];
- qreal stackCos[maxStacks];
- for (int slice = 0; slice < slices; ++slice) {
- qreal angle = 2 * M_PI * slice / slices;
- sliceSin[slice] = qFastSin(angle);
- sliceCos[slice] = qFastCos(angle);
- }
- sliceSin[slices] = sliceSin[0]; // Join first and last slice.
- sliceCos[slices] = sliceCos[0];
- for (int stack = 0; stack <= stacks; ++stack) {
- qreal angle = M_PI * stack / stacks;
- stackSin[stack] = qFastSin(angle);
- stackCos[stack] = qFastCos(angle);
- }
- stackSin[0] = 0.0f; // Come to a point at the poles.
- stackSin[stacks] = 0.0f;
-
- // Create the stacks.
- for (int stack = 0; stack < stacks; ++stack) {
- QGeometryData prim;
- qreal z = radius * stackCos[stack];
- qreal nextz = radius * stackCos[stack + 1];
- qreal s = stackSin[stack];
- qreal nexts = stackSin[stack + 1];
- qreal c = stackCos[stack];
- qreal nextc = stackCos[stack + 1];
- qreal r = radius * s;
- qreal nextr = radius * nexts;
- for (int slice = 0; slice <= slices; ++slice) {
- prim.appendVertex
- (QVector3D(nextr * sliceSin[slice],
- nextr * sliceCos[slice], nextz));
- prim.appendNormal
- (QVector3D(sliceSin[slice] * nexts,
- sliceCos[slice] * nexts, nextc));
- prim.appendTexCoord
- (QVector2D(1.0f - qreal(slice) / slices,
- 1.0f - qreal(stack + 1) / stacks));
-
- prim.appendVertex
- (QVector3D(r * sliceSin[slice],
- r * sliceCos[slice], z));
- prim.appendNormal
- (QVector3D(sliceSin[slice] * s,
- sliceCos[slice] * s, c));
- prim.appendTexCoord
- (QVector2D(1.0f - qreal(slice) / slices,
- 1.0f - qreal(stack) / stacks));
- }
- builder.addQuadStrip(prim);
- }
-
- return builder;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglsphere.h b/src/threed/geometry/qglsphere.h
deleted file mode 100644
index aa4e6cd3..00000000
--- a/src/threed/geometry/qglsphere.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSPHERE_H
-#define QGLSPHERE_H
-
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLBuilder;
-
-class Q_QT3D_EXPORT QGLSphere
-{
-public:
- explicit QGLSphere(qreal diameter = 1.0f, int depth = 5)
- : m_diameter(diameter), m_subdivisionDepth(depth) {}
- virtual ~QGLSphere();
-
- qreal diameter() const { return m_diameter; }
- void setDiameter(qreal diameter) { m_diameter = diameter; }
-
- int subdivisionDepth() const { return m_subdivisionDepth; }
- void setSubdivisionDepth(int depth) { m_subdivisionDepth = depth; }
-
-private:
- qreal m_diameter;
- int m_subdivisionDepth;
-};
-
-Q_QT3D_EXPORT QGLBuilder& operator<<(QGLBuilder& builder, const QGLSphere& sphere);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/qglteapot.cpp b/src/threed/geometry/qglteapot.cpp
deleted file mode 100644
index 175c6e9b..00000000
--- a/src/threed/geometry/qglteapot.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglteapot.h"
-#include "qglteapot_data_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLTeapot
- \brief The QGLTeapot class represents a 3D teapot object.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- The classic 3D "Utah Teapot" was originally drawn by Martin Newell
- in 1975. The vertex data was made publicly available by him and
- it has been a standard 3D test object ever since.
-
- For more information on the history of the "Utah Teapot", see
- Wikipedia, http://en.wikipedia.org/wiki/Utah_teapot.
-
- The following example code uses QGLTeapot to draw a teapot of size
- 0.5 at the origin:
-
- \code
- QGLBuilder builder;
- builder << QGLTeapot();
- teapot = builder.finalizedSceneNode();
-
- painter.modelViewMatrix().scale(0.5f);
- teapot->draw(painter);
- \endcode
-
- The QGLTeapot object contains a lot of vertex data once it has
- been subdivided into triangles. It is recommended that instances
- of this class be created at startup, added to a QGLBuilder,
- and then the finalized scene node can be reused over and over.
-
- \sa QGLBezierPatches
-*/
-
-/*!
- Constructs a new 3D teapot geometry object.
-*/
-QGLTeapot::QGLTeapot()
-{
- QVector3DArray positions;
- for (int pindex = 0; pindex < teapotPatchCount * 16; ++pindex) {
- int vindex = teapotPatchData[pindex];
- positions.append(teapotBezierVertexData[vindex * 3],
- teapotBezierVertexData[vindex * 3 + 1],
- teapotBezierVertexData[vindex * 3 + 2]);
- }
- setPositions(positions);
- setSubdivisionDepth(teapotDepth);
-}
-
-/*!
- Destroys this teapot geometry object.
-*/
-QGLTeapot::~QGLTeapot()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qglteapot.h b/src/threed/geometry/qglteapot.h
deleted file mode 100644
index 904e4910..00000000
--- a/src/threed/geometry/qglteapot.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEAPOT_H
-#define QGLTEAPOT_H
-
-#include "qglbezierpatches.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLTeapot : public QGLBezierPatches
-{
-public:
- QGLTeapot();
- ~QGLTeapot();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/geometry/qglteapot_data_p.h b/src/threed/geometry/qglteapot_data_p.h
deleted file mode 100644
index 56554822..00000000
--- a/src/threed/geometry/qglteapot_data_p.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEAPOT_DATA_P_H
-#define QGLTEAPOT_DATA_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.
-//
-
-#include "qglbezierpatches.h"
-
-// Generated from teapot.txt by meshcvt, depth = 4
-
-#define teapotBezierVertexCount 306
-#define teapotBezierVertexStride 3
-#define teapotPatchCount 32
-#define teapotDepth 4
-static float const teapotBezierVertexData[] = {
- 0.700000f, 0.450000f, -0.000000f,
- 0.700000f, 0.450000f, 0.392000f,
- 0.392000f, 0.450000f, 0.700000f,
- 0.000000f, 0.450000f, 0.700000f,
- 0.668750f, 0.515625f, -0.000000f,
- 0.668750f, 0.515625f, 0.374500f,
- 0.374500f, 0.515625f, 0.668750f,
- 0.000000f, 0.515625f, 0.668750f,
- 0.718750f, 0.515625f, -0.000000f,
- 0.718750f, 0.515625f, 0.402500f,
- 0.402500f, 0.515625f, 0.718750f,
- 0.000000f, 0.515625f, 0.718750f,
- 0.750000f, 0.450000f, -0.000000f,
- 0.750000f, 0.450000f, 0.420000f,
- 0.420000f, 0.450000f, 0.750000f,
- 0.000000f, 0.450000f, 0.750000f,
- -0.392000f, 0.450000f, 0.700000f,
- -0.700000f, 0.450000f, 0.392000f,
- -0.700000f, 0.450000f, -0.000000f,
- -0.374500f, 0.515625f, 0.668750f,
- -0.668750f, 0.515625f, 0.374500f,
- -0.668750f, 0.515625f, -0.000000f,
- -0.402500f, 0.515625f, 0.718750f,
- -0.718750f, 0.515625f, 0.402500f,
- -0.718750f, 0.515625f, -0.000000f,
- -0.420000f, 0.450000f, 0.750000f,
- -0.750000f, 0.450000f, 0.420000f,
- -0.750000f, 0.450000f, -0.000000f,
- -0.700000f, 0.450000f, -0.392000f,
- -0.392000f, 0.450000f, -0.700000f,
- 0.000000f, 0.450000f, -0.700000f,
- -0.668750f, 0.515625f, -0.374500f,
- -0.374500f, 0.515625f, -0.668750f,
- 0.000000f, 0.515625f, -0.668750f,
- -0.718750f, 0.515625f, -0.402500f,
- -0.402500f, 0.515625f, -0.718750f,
- 0.000000f, 0.515625f, -0.718750f,
- -0.750000f, 0.450000f, -0.420000f,
- -0.420000f, 0.450000f, -0.750000f,
- 0.000000f, 0.450000f, -0.750000f,
- 0.392000f, 0.450000f, -0.700000f,
- 0.700000f, 0.450000f, -0.392000f,
- 0.374500f, 0.515625f, -0.668750f,
- 0.668750f, 0.515625f, -0.374500f,
- 0.402500f, 0.515625f, -0.718750f,
- 0.718750f, 0.515625f, -0.402500f,
- 0.420000f, 0.450000f, -0.750000f,
- 0.750000f, 0.450000f, -0.420000f,
- 0.875000f, 0.187500f, -0.000000f,
- 0.875000f, 0.187500f, 0.490000f,
- 0.490000f, 0.187500f, 0.875000f,
- 0.000000f, 0.187500f, 0.875000f,
- 1.000000f, -0.075000f, -0.000000f,
- 1.000000f, -0.075000f, 0.560000f,
- 0.560000f, -0.075000f, 1.000000f,
- 0.000000f, -0.075000f, 1.000000f,
- 1.000000f, -0.300000f, -0.000000f,
- 1.000000f, -0.300000f, 0.560000f,
- 0.560000f, -0.300000f, 1.000000f,
- 0.000000f, -0.300000f, 1.000000f,
- -0.490000f, 0.187500f, 0.875000f,
- -0.875000f, 0.187500f, 0.490000f,
- -0.875000f, 0.187500f, -0.000000f,
- -0.560000f, -0.075000f, 1.000000f,
- -1.000000f, -0.075000f, 0.560000f,
- -1.000000f, -0.075000f, -0.000000f,
- -0.560000f, -0.300000f, 1.000000f,
- -1.000000f, -0.300000f, 0.560000f,
- -1.000000f, -0.300000f, -0.000000f,
- -0.875000f, 0.187500f, -0.490000f,
- -0.490000f, 0.187500f, -0.875000f,
- 0.000000f, 0.187500f, -0.875000f,
- -1.000000f, -0.075000f, -0.560000f,
- -0.560000f, -0.075000f, -1.000000f,
- 0.000000f, -0.075000f, -1.000000f,
- -1.000000f, -0.300000f, -0.560000f,
- -0.560000f, -0.300000f, -1.000000f,
- 0.000000f, -0.300000f, -1.000000f,
- 0.490000f, 0.187500f, -0.875000f,
- 0.875000f, 0.187500f, -0.490000f,
- 0.560000f, -0.075000f, -1.000000f,
- 1.000000f, -0.075000f, -0.560000f,
- 0.560000f, -0.300000f, -1.000000f,
- 1.000000f, -0.300000f, -0.560000f,
- 1.000000f, -0.525000f, -0.000000f,
- 1.000000f, -0.525000f, 0.560000f,
- 0.560000f, -0.525000f, 1.000000f,
- 0.000000f, -0.525000f, 1.000000f,
- 0.750000f, -0.637500f, -0.000000f,
- 0.750000f, -0.637500f, 0.420000f,
- 0.420000f, -0.637500f, 0.750000f,
- 0.000000f, -0.637500f, 0.750000f,
- 0.750000f, -0.675000f, -0.000000f,
- 0.750000f, -0.675000f, 0.420000f,
- 0.420000f, -0.675000f, 0.750000f,
- 0.000000f, -0.675000f, 0.750000f,
- -0.560000f, -0.525000f, 1.000000f,
- -1.000000f, -0.525000f, 0.560000f,
- -1.000000f, -0.525000f, -0.000000f,
- -0.420000f, -0.637500f, 0.750000f,
- -0.750000f, -0.637500f, 0.420000f,
- -0.750000f, -0.637500f, -0.000000f,
- -0.420000f, -0.675000f, 0.750000f,
- -0.750000f, -0.675000f, 0.420000f,
- -0.750000f, -0.675000f, -0.000000f,
- -1.000000f, -0.525000f, -0.560000f,
- -0.560000f, -0.525000f, -1.000000f,
- 0.000000f, -0.525000f, -1.000000f,
- -0.750000f, -0.637500f, -0.420000f,
- -0.420000f, -0.637500f, -0.750000f,
- 0.000000f, -0.637500f, -0.750000f,
- -0.750000f, -0.675000f, -0.420000f,
- -0.420000f, -0.675000f, -0.750000f,
- 0.000000f, -0.675000f, -0.750000f,
- 0.560000f, -0.525000f, -1.000000f,
- 1.000000f, -0.525000f, -0.560000f,
- 0.420000f, -0.637500f, -0.750000f,
- 0.750000f, -0.637500f, -0.420000f,
- 0.420000f, -0.675000f, -0.750000f,
- 0.750000f, -0.675000f, -0.420000f,
- -0.800000f, 0.262500f, -0.000000f,
- -0.800000f, 0.262500f, 0.150000f,
- -0.750000f, 0.375000f, 0.150000f,
- -0.750000f, 0.375000f, -0.000000f,
- -1.150000f, 0.262500f, -0.000000f,
- -1.150000f, 0.262500f, 0.150000f,
- -1.250000f, 0.375000f, 0.150000f,
- -1.250000f, 0.375000f, -0.000000f,
- -1.350000f, 0.262500f, -0.000000f,
- -1.350000f, 0.262500f, 0.150000f,
- -1.500000f, 0.375000f, 0.150000f,
- -1.500000f, 0.375000f, -0.000000f,
- -1.350000f, 0.150000f, -0.000000f,
- -1.350000f, 0.150000f, 0.150000f,
- -1.500000f, 0.150000f, 0.150000f,
- -1.500000f, 0.150000f, -0.000000f,
- -0.750000f, 0.375000f, -0.150000f,
- -0.800000f, 0.262500f, -0.150000f,
- -1.250000f, 0.375000f, -0.150000f,
- -1.150000f, 0.262500f, -0.150000f,
- -1.500000f, 0.375000f, -0.150000f,
- -1.350000f, 0.262500f, -0.150000f,
- -1.500000f, 0.150000f, -0.150000f,
- -1.350000f, 0.150000f, -0.150000f,
- -1.350000f, 0.037500f, -0.000000f,
- -1.350000f, 0.037500f, 0.150000f,
- -1.500000f, -0.075000f, 0.150000f,
- -1.500000f, -0.075000f, -0.000000f,
- -1.250000f, -0.187500f, -0.000000f,
- -1.250000f, -0.187500f, 0.150000f,
- -1.325000f, -0.281250f, 0.150000f,
- -1.325000f, -0.281250f, -0.000000f,
- -1.000000f, -0.300000f, 0.150000f,
- -0.950000f, -0.450000f, 0.150000f,
- -0.950000f, -0.450000f, -0.000000f,
- -1.500000f, -0.075000f, -0.150000f,
- -1.350000f, 0.037500f, -0.150000f,
- -1.325000f, -0.281250f, -0.150000f,
- -1.250000f, -0.187500f, -0.150000f,
- -0.950000f, -0.450000f, -0.150000f,
- -1.000000f, -0.300000f, -0.150000f,
- 0.850000f, -0.037500f, -0.000000f,
- 0.850000f, -0.037500f, 0.330000f,
- 0.850000f, -0.450000f, 0.330000f,
- 0.850000f, -0.450000f, -0.000000f,
- 1.300000f, -0.037500f, -0.000000f,
- 1.300000f, -0.037500f, 0.330000f,
- 1.550000f, -0.337500f, 0.330000f,
- 1.550000f, -0.337500f, -0.000000f,
- 1.150000f, 0.300000f, -0.000000f,
- 1.150000f, 0.300000f, 0.125000f,
- 1.200000f, 0.262500f, 0.125000f,
- 1.200000f, 0.262500f, -0.000000f,
- 1.350000f, 0.450000f, -0.000000f,
- 1.350000f, 0.450000f, 0.125000f,
- 1.650000f, 0.450000f, 0.125000f,
- 1.650000f, 0.450000f, -0.000000f,
- 0.850000f, -0.450000f, -0.330000f,
- 0.850000f, -0.037500f, -0.330000f,
- 1.550000f, -0.337500f, -0.330000f,
- 1.300000f, -0.037500f, -0.330000f,
- 1.200000f, 0.262500f, -0.125000f,
- 1.150000f, 0.300000f, -0.125000f,
- 1.650000f, 0.450000f, -0.125000f,
- 1.350000f, 0.450000f, -0.125000f,
- 1.400000f, 0.487500f, -0.000000f,
- 1.400000f, 0.487500f, 0.125000f,
- 1.762500f, 0.496875f, 0.125000f,
- 1.762500f, 0.496875f, -0.000000f,
- 1.450000f, 0.487500f, -0.000000f,
- 1.450000f, 0.487500f, 0.075000f,
- 1.725000f, 0.506250f, 0.075000f,
- 1.725000f, 0.506250f, -0.000000f,
- 1.400000f, 0.450000f, -0.000000f,
- 1.400000f, 0.450000f, 0.075000f,
- 1.600000f, 0.450000f, 0.075000f,
- 1.600000f, 0.450000f, -0.000000f,
- 1.762500f, 0.496875f, -0.125000f,
- 1.400000f, 0.487500f, -0.125000f,
- 1.725000f, 0.506250f, -0.075000f,
- 1.450000f, 0.487500f, -0.075000f,
- 1.600000f, 0.450000f, -0.075000f,
- 1.400000f, 0.450000f, -0.075000f,
- 0.000000f, 0.825000f, -0.000000f,
- 0.000000f, 0.825000f, 0.001000f,
- 0.001000f, 0.825000f, -0.000000f,
- 0.400000f, 0.825000f, -0.000000f,
- 0.400000f, 0.825000f, 0.225000f,
- 0.225000f, 0.825000f, 0.400000f,
- 0.000000f, 0.825000f, 0.400000f,
- 0.000000f, 0.675000f, -0.000000f,
- 0.100000f, 0.600000f, -0.000000f,
- 0.100000f, 0.600000f, 0.056000f,
- 0.056000f, 0.600000f, 0.100000f,
- 0.000000f, 0.600000f, 0.100000f,
- -0.001000f, 0.825000f, -0.000000f,
- -0.225000f, 0.825000f, 0.400000f,
- -0.400000f, 0.825000f, 0.225000f,
- -0.400000f, 0.825000f, -0.000000f,
- -0.056000f, 0.600000f, 0.100000f,
- -0.100000f, 0.600000f, 0.056000f,
- -0.100000f, 0.600000f, -0.000000f,
- 0.000000f, 0.825000f, -0.001000f,
- -0.400000f, 0.825000f, -0.225000f,
- -0.225000f, 0.825000f, -0.400000f,
- 0.000000f, 0.825000f, -0.400000f,
- -0.100000f, 0.600000f, -0.056000f,
- -0.056000f, 0.600000f, -0.100000f,
- 0.000000f, 0.600000f, -0.100000f,
- 0.225000f, 0.825000f, -0.400000f,
- 0.400000f, 0.825000f, -0.225000f,
- 0.056000f, 0.600000f, -0.100000f,
- 0.100000f, 0.600000f, -0.056000f,
- 0.200000f, 0.525000f, -0.000000f,
- 0.200000f, 0.525000f, 0.112000f,
- 0.112000f, 0.525000f, 0.200000f,
- 0.000000f, 0.525000f, 0.200000f,
- 0.650000f, 0.525000f, -0.000000f,
- 0.650000f, 0.525000f, 0.364000f,
- 0.364000f, 0.525000f, 0.650000f,
- 0.000000f, 0.525000f, 0.650000f,
- 0.650000f, 0.450000f, -0.000000f,
- 0.650000f, 0.450000f, 0.364000f,
- 0.364000f, 0.450000f, 0.650000f,
- 0.000000f, 0.450000f, 0.650000f,
- -0.112000f, 0.525000f, 0.200000f,
- -0.200000f, 0.525000f, 0.112000f,
- -0.200000f, 0.525000f, -0.000000f,
- -0.364000f, 0.525000f, 0.650000f,
- -0.650000f, 0.525000f, 0.364000f,
- -0.650000f, 0.525000f, -0.000000f,
- -0.364000f, 0.450000f, 0.650000f,
- -0.650000f, 0.450000f, 0.364000f,
- -0.650000f, 0.450000f, -0.000000f,
- -0.200000f, 0.525000f, -0.112000f,
- -0.112000f, 0.525000f, -0.200000f,
- 0.000000f, 0.525000f, -0.200000f,
- -0.650000f, 0.525000f, -0.364000f,
- -0.364000f, 0.525000f, -0.650000f,
- 0.000000f, 0.525000f, -0.650000f,
- -0.650000f, 0.450000f, -0.364000f,
- -0.364000f, 0.450000f, -0.650000f,
- 0.000000f, 0.450000f, -0.650000f,
- 0.112000f, 0.525000f, -0.200000f,
- 0.200000f, 0.525000f, -0.112000f,
- 0.364000f, 0.525000f, -0.650000f,
- 0.650000f, 0.525000f, -0.364000f,
- 0.364000f, 0.450000f, -0.650000f,
- 0.650000f, 0.450000f, -0.364000f,
- 0.000000f, -0.750000f, -0.000000f,
- 0.750000f, -0.675000f, -0.000000f,
- 0.750000f, -0.675000f, -0.420000f,
- 0.420000f, -0.675000f, -0.750000f,
- 0.000000f, -0.675000f, -0.750000f,
- 0.750000f, -0.712500f, -0.000000f,
- 0.750000f, -0.712500f, -0.420000f,
- 0.420000f, -0.712500f, -0.750000f,
- 0.000000f, -0.712500f, -0.750000f,
- 0.712500f, -0.750000f, -0.000000f,
- 0.712500f, -0.750000f, -0.399000f,
- 0.399000f, -0.750000f, -0.712500f,
- 0.000000f, -0.750000f, -0.712500f,
- -0.420000f, -0.675000f, -0.750000f,
- -0.750000f, -0.675000f, -0.420000f,
- -0.750000f, -0.675000f, -0.000000f,
- -0.420000f, -0.712500f, -0.750000f,
- -0.750000f, -0.712500f, -0.420000f,
- -0.750000f, -0.712500f, -0.000000f,
- -0.399000f, -0.750000f, -0.712500f,
- -0.712500f, -0.750000f, -0.399000f,
- -0.712500f, -0.750000f, -0.000000f,
- -0.750000f, -0.675000f, 0.420000f,
- -0.420000f, -0.675000f, 0.750000f,
- 0.000000f, -0.675000f, 0.750000f,
- -0.750000f, -0.712500f, 0.420000f,
- -0.420000f, -0.712500f, 0.750000f,
- 0.000000f, -0.712500f, 0.750000f,
- -0.712500f, -0.750000f, 0.399000f,
- -0.399000f, -0.750000f, 0.712500f,
- 0.000000f, -0.750000f, 0.712500f,
- 0.420000f, -0.675000f, 0.750000f,
- 0.750000f, -0.675000f, 0.420000f,
- 0.420000f, -0.712500f, 0.750000f,
- 0.750000f, -0.712500f, 0.420000f,
- 0.399000f, -0.750000f, 0.712500f,
- 0.712500f, -0.750000f, 0.399000f
-};
-
-static ushort const teapotPatchData[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27,
- 18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39,
- 30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12,
- 12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68,
- 27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77,
- 39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56,
- 56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104,
- 68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113,
- 77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92,
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
- 123, 136, 137, 120, 127, 138, 139, 124, 131, 140, 141, 128, 135, 142, 143, 132,
- 132, 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 151, 68, 152, 153, 154,
- 135, 142, 143, 132, 147, 155, 156, 144, 151, 157, 158, 148, 154, 159, 160, 68,
- 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
- 164, 177, 178, 161, 168, 179, 180, 165, 172, 181, 182, 169, 176, 183, 184, 173,
- 173, 174, 175, 176, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
- 176, 183, 184, 173, 188, 197, 198, 185, 192, 199, 200, 189, 196, 201, 202, 193,
- 203, 203, 203, 203, 206, 207, 208, 209, 210, 210, 210, 210, 211, 212, 213, 214,
- 203, 203, 203, 203, 209, 216, 217, 218, 210, 210, 210, 210, 214, 219, 220, 221,
- 203, 203, 203, 203, 218, 223, 224, 225, 210, 210, 210, 210, 221, 226, 227, 228,
- 203, 203, 203, 203, 225, 229, 230, 206, 210, 210, 210, 210, 228, 231, 232, 211,
- 211, 212, 213, 214, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
- 214, 219, 220, 221, 236, 245, 246, 247, 240, 248, 249, 250, 244, 251, 252, 253,
- 221, 226, 227, 228, 247, 254, 255, 256, 250, 257, 258, 259, 253, 260, 261, 262,
- 228, 231, 232, 211, 256, 263, 264, 233, 259, 265, 266, 237, 262, 267, 268, 241,
- 269, 269, 269, 269, 278, 279, 280, 281, 274, 275, 276, 277, 270, 271, 272, 273,
- 269, 269, 269, 269, 281, 288, 289, 290, 277, 285, 286, 287, 273, 282, 283, 284,
- 269, 269, 269, 269, 290, 297, 298, 299, 287, 294, 295, 296, 284, 291, 292, 293,
- 269, 269, 269, 269, 299, 304, 305, 278, 296, 302, 303, 274, 293, 300, 301, 270
-};
-
-#endif
diff --git a/src/threed/geometry/qlogicalvertex.cpp b/src/threed/geometry/qlogicalvertex.cpp
deleted file mode 100644
index 84dc09ae..00000000
--- a/src/threed/geometry/qlogicalvertex.cpp
+++ /dev/null
@@ -1,420 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qlogicalvertex.h"
-#include "qvector_utils_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QLogicalVertex
- \brief The QLogicalVertex class references QGeometryData at a single vertex.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::geometry
-
- QLogicalVertex instances are a convenience class for use with
- QGeometryData. A QLogicalVertex simply references through to the data
- in a QGeometryData for a particular vertex, providing accessors to fetch
- position, texture coordinates, and other values.
-
- Create a QLogicalVertex referring to a particular QGeometryData instance:
- \code
- QGeometryData data;
- data.appendVertex(QVector3D(1, 2, 3));
-
- // construct a QLogicalVertex referring to the first vertex in data
- // the QGeometryData is implicitly shared with lv
- QLogicalVertex lv(data, 0);
- // lv.vertex() == QVector3D(1, 2, 3)
- \endcode
- This is inexpensive and no new storage is allocated for the actual data,
- just the reference and index.
-
- With logical vertices instances referencing large QGeometryData instances,
- avoid modifying the instance:
- \code
- // careful - assigning to a QLogicalVertex which refers to an external
- // QGeometryData will result in a possibly expensive copy-on-write
- lv.setVertex(3, 2, 1);
- \endcode
-
- Create a QLogicalVertex with its own QGeometryData internally:
- \code
- QLogicalVertex lv;
- // no copy on write here - internal QGeometryData is not shared
- lv.setVertex(1, 2, 3);
- \endcode
-
- Assign an instance of QLogicalVertex:
- \code
- QLogicalVertex lv2;
- lv2 = data.logicalVertexAt(0);
- \endcode
- Although lv2 gets its own internal QGeometryData which is then immediately
- thrown away by the assignment, because of lazy initialization in
- QGeometryData the cost is negligible.
-
- Use the fields() and hasField() functions to determine if a particular
- field is present in the vertex. Accessing non-existent data will cause
- an assert in debug mode (from the underlying QArray), and give
- undefined behaviour in release mode.
-
- \sa QGeometryData, QGLBuilder
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex()
- Constructs a new invalid QLogicalVertex which has no data.
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex(QGeometryData data, int index)
- Constructs a new QLogicalVertex referencing the \a data at \a index.
- Note that if this QLogicalVertex is modified, by calling vertex() or
- setNormal() for example, then a copy-on-write for \a data will be
- triggered.
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex(const QVector3D &a)
- Constructs a new QLogicalVertex with a vertex set to \a a.
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex(const QVector3D &a, const QVector3D &n);
- Constructs a new QLogicalVertex with a vertex set to \a a, and normal set to \a n.
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex(const QVector3D &a, const QVector3D &n, const QVector2D &t)
- Constructs a new QLogicalVertex with its vertex value set to \a a, normal set
- to \a n, and texture set to \a t. By default \a n is the null QVector3D,
- and \a t is the InvalidTexCoord. If \a n is null then hasType(QLogicalVertex::Normal)
- will return false. Likewise if \a t is the InvalidTexCoord then
- hasType(QLogicalVertex::Texture) will return false.
-*/
-
-/*!
- \fn QLogicalVertex::QLogicalVertex(const QVector3D &a, QColor4ub color)
- Constructs a new QLogicalVertex with its vertex value set to \a a,
- color value set to \a color.
-*/
-
-/*!
- \fn QLogicalVertex::~QLogicalVertex()
- Destroys this QLogicalVertex reclaiming any resources.
-*/
-
-/*!
- \fn const QVector3D &QLogicalVertex::vertex() const
- Returns a const reference to the vertex value for this vertex.
-*/
-
-/*!
- \fn void QLogicalVertex::setVertex(const QVector3D &v)
- Sets the vertex value for this vertex to \a v.
-*/
-
-/*!
- \fn QVector3D &QLogicalVertex::vertex()
- Returns a modifiable reference to the vertex value.
-*/
-
-/*!
- \fn QLogicalVertex::operator QVector3D ()
- Returns a copy of the vertex value, by casting as a QVector3D. This
- allows passing of a QLogicalVertex to functions that expect a QVector3D.
-*/
-
-/*!
- \fn QVariant QLogicalVertex::attribute(QGL::VertexAttribute field) const
- Returns the attribute value for \a field. The \a field defaults
- to QGL::CustomVertex0.
-*/
-
-/*!
- \fn void QLogicalVertex::setAttribute(float value, QGL::VertexAttribute field)
- Sets the float attribute \a value at \a field. The \a field
- defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn void QLogicalVertex::setAttribute(const QVector2D &v, QGL::VertexAttribute field)
- Sets the QVector2D attribute \a v at \a field. The \a field
- defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn void QLogicalVertex::setAttribute(const QVector3D &v, QGL::VertexAttribute field)
- Sets the QVector3D attribute \a v at \a field. The \a field
- defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn float &QLogicalVertex::floatAttribute(QGL::VertexAttribute field)
- Returns a modifiable reference to the attribute at \a field, which
- must be a float. The \a field defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn QVector2D &QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field)
- Returns a modifiable reference to the attribute at \a field, which
- must be a QVector2D. The \a field defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn QVector3D &QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0);
- Returns a modifiable reference to the attribute at \a field, which
- must be a QVector3D. The \a field defaults to QGL::CustomVertex0.
-*/
-
-/*!
- \fn float QLogicalVertex::floatAttribute(QGL::VertexAttribute field) const
- Returns the attribute at \a field. The \a field defaults to QGL::CustomVertex0.
- The attribute must be a float value.
-*/
-
-/*!
- \fn QVector2D QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field) const
- Returns the attribute at \a field. The \a field defaults to QGL::CustomVertex0.
- The attribute must be a QVector2D value.
-*/
-
-/*!
- \fn QVector3D QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field) const
- Returns the attribute at \a field. The \a field defaults to QGL::CustomVertex0.
- The attribute must be a QVector3D value.
-*/
-
-/*!
- \fn QCustomDataArray::ElementType QLogicalVertex::attributeType(QGL::VertexAttribute field)
- Returns the element type for the attribute \a field.
-*/
-
-/*!
- \fn const QVector3D &QLogicalVertex::normal() const
- Returns a const reference to the normal value for this vertex.
-*/
-
-/*!
- \fn void QLogicalVertex::setNormal(const QVector3D &n)
- Sets the normal value for this vertex to \a n.
-*/
-
-/*!
- \fn QVector3D &QLogicalVertex::normal()
- Returns a modifiable reference to the normal value for this vertex.
-*/
-
-/*!
- \fn QVector2D QLogicalVertex::texCoord(QGL::VertexAttribute field) const
- Returns a copy of the texture coordinate value at \a field for this vertex.
- The \a field defaults to QGL::TextureCoord0.
-*/
-
-/*!
- \fn void QLogicalVertex::setTexCoord(const QVector2D &t, QGL::VertexAttribute field)
- Sets the texture coordinate at \a field for this vertex to \a t.
- The \a field defaults to QGL::TextureCoord0.
-*/
-
-/*!
- \fn QVector2D &QLogicalVertex::texCoordRef(QGL::VertexAttribute field)
- Returns a modifiable reference to the texture coordinate for this vertex.
- The \a field defaults to QGL::TextureCoord0.
-*/
-
-/*!
- \fn QColor4ub QLogicalVertex::color() const
- Returns a const reference to the color value for this vertex.
-*/
-
-/*!
- \fn void QLogicalVertex::setColor(const QColor4ub &c)
- Sets the color value for this vertex to \a c.
-*/
-
-/*!
- \fn QColor4ub &QLogicalVertex::colorRef()
- Returns a modifiable reference to the color value for this vertex.
-*/
-
-/*!
- \fn bool QLogicalVertex::hasField(QGL::VertexAttribute type) const
- Returns true if this vertex has data field \a type, and false otherwise.
-
- In general check to see if a logical vertex has a particular field
- type before attempting to access it. In debug mode accessing a
- non-existent field will cause an assert; but in release mode the
- behaviour is undefined.
-*/
-
-/*!
- \fn quint32 QLogicalVertex::fields() const
- Returns a bit-mask of the fields in this logical vertex. Test the
- fields like this:
- \code
- if (vertex.fields() & QGL::fieldMask(QGL::TextureCoord0))
- tex = vertex.texCoord();
- \endcode
-
- \sa QGeometryData::fields()
-*/
-
-/*!
- \fn int QLogicalVertex::index() const
- Returns the index at which this logical vertex's data is located in
- its associated QGeometryData; or -1 if this vertex is null.
-*/
-
-/*!
- \fn QGeometryData QLogicalVertex::data() const
- Returns a copy of the QGeometryData underlying this vertex. Note that
- the copy is not expensive in terms of performance due to implicit sharing
- unless the copy is modified (causing a copy-on-write).
-
- \sa QLogicalVertex::index()
-*/
-
-/*!
- \fn QGeometryData data() const
- Returns a copy of the QGeometryData associated with this vertex. Note
- that as long as the copy is not modified, this method is not expensive.
-*/
-
-/*!
- \fn bool QLogicalVertex::isNull() const
- Returns true if this vertex is null.
-
- \sa QLogicalVertex()
-*/
-
-/*!
- Returns true if \a rhs has exactly the same fields as this logical
- vertex, and each of those are equal to the corresponding field of the \a rhs.
-
- If either are null, then false is returned.
-*/
-bool QLogicalVertex::operator==(const QLogicalVertex &rhs) const
-{
- if (isNull() || rhs.isNull())
- return false;
- if (this == &rhs)
- return true;
- if (m_data.fields() != rhs.fields())
- return false;
- const quint32 mask = 0x01;
- quint32 fields = m_data.fields();
- for (int field = 0; fields; ++field, fields >>= 1)
- {
- if (mask & fields)
- {
- QGL::VertexAttribute attr = static_cast<QGL::VertexAttribute>(field);
- if (attr < QGL::TextureCoord0)
- {
- if (attr == QGL::Position)
- {
- if (!qFskCompare(vertex(), rhs.vertex()))
- return false;
- }
- else if (attr == QGL::Normal)
- {
- if (!qFskCompare(normal(), rhs.normal()))
- return false;
- }
- else
- {
- if (color() != rhs.color())
- return false;
- }
- }
- else if (attr < QGL::CustomVertex0)
- {
- if (!qFskCompare(texCoord(attr), rhs.texCoord(attr)))
- return false;
- }
- else
- {
- if (attribute(attr) != rhs.attribute(attr))
- return false;
- }
- }
- }
- return true;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QLogicalVertex &lv)
-{
- dbg.nospace();
- dbg << "QLogicalVertex(";
- if (lv.isNull())
- {
- dbg << " NULL";
- }
- else
- {
- if (lv.hasField(QGL::Position))
- dbg << "V:" << QVector3D(lv.vertex());
- else
- dbg << " (No Vertex)";
- if (lv.hasField(QGL::Normal))
- dbg << "N:" << QVector3D(lv.normal());
- else
- dbg << " (No Normal)";
- if (lv.hasField(QGL::TextureCoord0))
- dbg << "T:" << QVector2D(lv.texCoord());
- else
- dbg << " (No Texture)";
- if (lv.hasField(QGL::Color))
- dbg << "C:" << QColor4ub(lv.color());
- else
- dbg << " (No Color)";
- }
- dbg << " )";
- return dbg.space();
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/geometry/qlogicalvertex.h b/src/threed/geometry/qlogicalvertex.h
deleted file mode 100644
index 3a5d9b6b..00000000
--- a/src/threed/geometry/qlogicalvertex.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QLOGICALVERTEX_H
-#define QLOGICALVERTEX_H
-
-#include "qgeometrydata.h"
-#include "qcustomdataarray.h"
-
-QT_BEGIN_NAMESPACE
-
-// uncomment this to perform heavy checking of QLogicalVertex
-// #define QT3D_DEBUG_QLOGICALVERTEX 1
-
-class QLogicalVertex
-{
-public:
- inline QLogicalVertex();
- inline QLogicalVertex(QGeometryData data, int index);
- inline QLogicalVertex(const QVector3D &a);
- inline QLogicalVertex(const QVector3D &a, const QVector3D &n);
- inline QLogicalVertex(const QVector3D &a, const QVector3D &n, const QVector2D &t);
- inline QLogicalVertex(const QVector3D &a, QColor4ub color);
- ~QLogicalVertex() {}
-
- inline const QVector3D &vertex() const;
- inline void setVertex(const QVector3D &v);
- inline QVector3D &vertex();
-
- operator QVector3D () { return vertex(); }
-
- inline QVariant attribute(QGL::VertexAttribute field = QGL::CustomVertex0) const;
- inline void setAttribute(float value, QGL::VertexAttribute attr);
- inline void setAttribute(const QVector2D &v, QGL::VertexAttribute field = QGL::CustomVertex0);
- inline void setAttribute(const QVector3D &v, QGL::VertexAttribute field = QGL::CustomVertex0);
- inline float &floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0);
- inline QVector2D &vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0);
- inline QVector3D &vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0);
- inline float floatAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const;
- inline QVector2D vector2DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const;
- inline QVector3D vector3DAttribute(QGL::VertexAttribute field = QGL::CustomVertex0) const;
- inline QCustomDataArray::ElementType attributeType(QGL::VertexAttribute field = QGL::CustomVertex0);
-
- inline const QVector3D &normal() const;
- inline void setNormal(const QVector3D &n);
- inline QVector3D &normal();
-
- inline const QColor4ub &color() const;
- inline void setColor(const QColor4ub &c);
- inline QColor4ub &colorRef();
-
- inline const QVector2D &texCoord(QGL::VertexAttribute attr = QGL::TextureCoord0) const;
- inline void setTexCoord(const QVector2D &t, QGL::VertexAttribute attr = QGL::TextureCoord0);
- inline QVector2D &texCoordRef(QGL::VertexAttribute attr = QGL::TextureCoord0);
-
- inline bool hasField(QGL::VertexAttribute type) const;
- inline quint32 fields() const;
- inline int index() const;
- inline QGeometryData data() const;
- inline bool isNull() const;
-
- bool operator==(const QLogicalVertex &rhs) const;
-
-private:
- QGeometryData m_data;
- int m_index;
-};
-
-inline QLogicalVertex::QLogicalVertex()
- : m_index(-1)
-{
-}
-
-inline QLogicalVertex::QLogicalVertex(QGeometryData data, int index)
- : m_data(data)
- , m_index(index)
-{
- Q_ASSERT(index < data.count());
-#ifdef QT3D_DEBUG_QLOGICALVERTEX
- data.check();
-#endif
-}
-
-inline QLogicalVertex::QLogicalVertex(const QVector3D &a)
- : m_index(0)
-{
- m_data.appendVertex(a);
-}
-
-inline QLogicalVertex::QLogicalVertex(const QVector3D &a, const QVector3D &n)
- : m_index(0)
-{
- m_data.appendVertex(a);
- m_data.appendNormal(n);
-}
-
-inline QLogicalVertex::QLogicalVertex(const QVector3D &a, const QVector3D &n, const QVector2D &t)
- : m_index(0)
-{
- m_data.appendVertex(a);
- m_data.appendNormal(n);
- m_data.appendTexCoord(t);
-}
-
-inline QLogicalVertex::QLogicalVertex(const QVector3D &a, QColor4ub color)
- : m_index(0)
-{
- m_data.appendVertex(a);
- m_data.appendColor(color);
-}
-
-inline const QVector3D &QLogicalVertex::vertex() const
-{
- return m_data.vertexAt(m_index);
-}
-
-inline void QLogicalVertex::setVertex(const QVector3D &v)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(QGL::Position))
- m_data.appendVertex(v);
- else
- m_data.vertex(m_index) = v;
-}
-
-inline QVector3D &QLogicalVertex::vertex()
-{
- return m_data.vertex(m_index);
-}
-
-inline QVariant QLogicalVertex::attribute(QGL::VertexAttribute attr) const
-{
- return m_data.attributes(attr).at(m_index);
-}
-
-inline void QLogicalVertex::setAttribute(float v, QGL::VertexAttribute attr)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(attr))
- m_data.appendAttribute(v, attr);
- else
- m_data.floatAttribute(m_index, attr) = v;
-}
-
-inline void QLogicalVertex::setAttribute(const QVector2D &v, QGL::VertexAttribute attr)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(attr))
- m_data.appendAttribute(v, attr);
- else
- m_data.vector2DAttribute(m_index, attr) = v;
-}
-
-inline void QLogicalVertex::setAttribute(const QVector3D &v, QGL::VertexAttribute attr)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(attr))
- m_data.appendAttribute(v, attr);
- else
- m_data.vector3DAttribute(m_index, attr) = v;
-}
-
-inline float &QLogicalVertex::floatAttribute(QGL::VertexAttribute field)
-{
- return m_data.floatAttribute(m_index, field);
-}
-
-inline QVector2D &QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field)
-{
- return m_data.vector2DAttribute(m_index, field);
-}
-
-inline QVector3D &QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field)
-{
-
- return m_data.vector3DAttribute(m_index, field);
-}
-
-inline float QLogicalVertex::floatAttribute(QGL::VertexAttribute field) const
-{
- return m_data.floatAttributeAt(m_index, field);
-}
-
-inline QVector2D QLogicalVertex::vector2DAttribute(QGL::VertexAttribute field) const
-{
- return m_data.vector2DAttributeAt(m_index, field);
-}
-
-inline QVector3D QLogicalVertex::vector3DAttribute(QGL::VertexAttribute field) const
-{
- return m_data.vector3DAttributeAt(m_index, field);
-}
-
-inline QCustomDataArray::ElementType QLogicalVertex::attributeType(QGL::VertexAttribute field)
-{
- return m_data.attributes(field).elementType();
-}
-
-inline const QVector3D &QLogicalVertex::normal() const
-{
- return m_data.normalAt(m_index);
-}
-
-inline void QLogicalVertex::setNormal(const QVector3D &n)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(QGL::Normal))
- m_data.appendNormal(n);
- else
- m_data.normal(m_index) = n;
-}
-
-inline QVector3D &QLogicalVertex::normal()
-{
- return m_data.normal(m_index);
-}
-
-inline const QVector2D &QLogicalVertex::texCoord(QGL::VertexAttribute attr) const
-{
- return m_data.texCoordAt(m_index, attr);
-}
-
-inline void QLogicalVertex::setTexCoord(const QVector2D &t, QGL::VertexAttribute attr)
-{
- Q_ASSERT(attr >= QGL::TextureCoord0 && attr <= QGL::TextureCoord2);
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(attr))
- m_data.appendTexCoord(t, attr);
- else
- m_data.texCoord(m_index, attr) = t;
-}
-
-inline QVector2D &QLogicalVertex::texCoordRef(QGL::VertexAttribute attr)
-{
- return m_data.texCoord(m_index, attr);
-}
-
-inline const QColor4ub &QLogicalVertex::color() const
-{
- return m_data.colorAt(m_index);
-}
-
-inline void QLogicalVertex::setColor(const QColor4ub &c)
-{
- if (m_index == -1)
- m_index = 0;
- if (m_index == m_data.count(QGL::Color))
- m_data.appendColor(c);
- else
- m_data.color(m_index) = c;
-}
-
-inline QColor4ub &QLogicalVertex::colorRef()
-{
- return m_data.color(m_index);
-}
-
-inline bool QLogicalVertex::hasField(QGL::VertexAttribute attr) const
-{
- return m_data.hasField(attr);
-}
-
-inline quint32 QLogicalVertex::fields() const
-{
- return m_data.fields();
-}
-
-inline int QLogicalVertex::index() const
-{
- return m_index;
-}
-
-inline bool QLogicalVertex::isNull() const
-{
- return (m_index == -1);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QLogicalVertex &section);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QLOGICALVERTEX_H
diff --git a/src/threed/geometry/qvector_utils_p.h b/src/threed/geometry/qvector_utils_p.h
deleted file mode 100644
index 3350ad6f..00000000
--- a/src/threed/geometry/qvector_utils_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QVECTOR_UTILS_P_H
-#define QVECTOR_UTILS_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.
-//
-
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector2d.h>
-
-// Replacement for qFuzzyCompare(QVector3D, QVector3D) and friends,
-// for a specific case where the results are going to be rendered
-// by the GPU onto a display.
-//
-// The accuracy of this comparison should not change. Especially it
-// should not change when you go from doubles to floats or when
-// you get close to zero. If two verts or lighting normals are
-// the same to within 5 places of floating point accuracy then they
-// will dislay as being on top of each other.
-//
-// Also this avoids doing 3 floating point multiplications every time
-// since the normal qFuzzyIsNull does a mul to scale the epsilon when
-// close to zero.
-
-inline bool qFskIsNull(double d)
-{
- return qAbs(d) <= 0.00001;
-}
-
-inline bool qFskIsNull(float f)
-{
- return qAbs(f) <= 0.00001f;
-}
-
-inline bool qFskCompare(float a, float b)
-{
- return qFskIsNull(a - b);
-}
-
-inline bool qFskCompare(double a, double b)
-{
- return qFskIsNull(a - b);
-}
-
-inline bool qFskCompare(const QVector3D &a, const QVector3D &b)
-{
- return (
- qFskIsNull(a.x() - b.x()) &&
- qFskIsNull(a.y() - b.y()) &&
- qFskIsNull(a.z() - b.z())
- );
-}
-
-inline bool qFskCompare(const QVector2D &a, const QVector2D &b)
-{
- return (
- qFskIsNull(a.x() - b.x()) &&
- qFskIsNull(a.y() - b.y())
- );
-}
-
-#endif // QVECTOR_UTILS_P_H
diff --git a/src/threed/global/global.pri b/src/threed/global/global.pri
deleted file mode 100644
index 2fac1022..00000000
--- a/src/threed/global/global.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += \
- global/qt3dglobal.h \
- global/qglnamespace.h
-SOURCES += \
- qglnamespace.cpp
diff --git a/src/threed/global/qglnamespace.cpp b/src/threed/global/qglnamespace.cpp
deleted file mode 100644
index 63418cf3..00000000
--- a/src/threed/global/qglnamespace.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglnamespace.h"
-#include <QtCore/qsize.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \namespace QGL
-
- \brief The QGL namespace contains miscellaneous identifiers
- used throughout the Qt3D module.
-*/
-
-/*!
- \enum QGL::VertexAttribute
- \since 4.8
- This enum defines the type of vertex attribute to set on an effect with QGLPainter::setVertexAttribute()
-
- \value Position The primary position of the vertex.
- \value Normal The normal at each vertex.
- \value Color The color at each vertex.
- \value TextureCoord0 The texture co-ordinate at each vertex for texture unit 0.
- \value TextureCoord1 The texture co-ordinate at each vertex for texture unit 1.
- \value TextureCoord2 The texture co-ordinate at each vertex for texture unit 2.
- \value CustomVertex0 First custom vertex attribute. Custom attributes
- can be used for any purpose: texture co-ordinates, colors,
- or other values of interest to shader programs.
- \value CustomVertex1 Second custom vertex attribute.
- \value UserVertex First user-assigned vertex attribute. Additional
- attributes can be assigned as UserVertex, UserVertex + 1, etc.
- Note that on OpenGL/ES 2.0 systems, usually the maximum
- number of vertex attributes is 8, which means that user-assigned
- vertex attributes will be out of range.
-*/
-
-/*!
- \enum QGL::Face
- \since 4.8
- This enum defines the faces to apply an operation to.
-
- \value FrontFaces Apply the operation to front faces only.
- \value BackFaces Apply the operation to back faces only.
- \value AllFaces Apply the operation to both front and back faces.
-*/
-
-/*!
- \enum QGL::DrawingMode
- \since 4.8
- This enum defines the type of OpenGL primitive to render with QGLPainter::draw().
-
- \value Points Draws a point at each of the specified vertices.
- \value Lines Draws a series of unconnected line segments, using two
- vertices for each line.
- \value LineLoop series of connected line segments, from the
- first to the last vertex, and then connecting the last
- vertex back to the first vertex.
- \value LineStrip Draws a series of connected line segments, from the
- first to the last vertex.
- \value Triangles Draws a series of triangles using three vertices from
- the enabled vertex arrays for each triangle.
- \value TriangleStrip Draws a series of triangles in a strip, starting
- with the first three vertices and then one extra vertex for each
- additional triangle.
- \value TriangleFan Draws a series of triangles that fan out around the
- first vertex in the enabled vertex arrays, starting with the
- first three vertices and then one extra vertex for each additional
- triangle.
- \value LinesAdjacency Draws a series of unconnected lines, using
- two vertices for each line to define the positions, and an
- additional vertices per line to define adjacent points.
- This drawing mode is only supported on OpenGL systems that
- have geometry shaders.
- \value LineStripAdjacency Draws a series of connected line segments,
- from the second to the second last vertex. The first and last
- vertices define adjacent points. This drawing mode is only
- supported on OpenGL systems that have geometry shaders.
- \value TrianglesAdjacency Draws a series of triangles using three
- vertices from the enabled vertex arrays for each triangle.
- An additional three vertices per triangle are supplied to
- define adjacent points. This drawing mode is only supported
- on OpenGL systems that have geometry shaders.
- \value TriangleStripAdjacency Draws a series of triangles in a strip,
- with additional vertices for points adjacent to the strip.
- This drawing mode is only supported on OpenGL systems that
- have geometry shaders.
-*/
-
-/*!
- \enum QGL::StandardEffect
- \since 4.8
- This enum defines a standard drawing effect for use with QGLPainter.
-
- \value FlatColor Single flat color specified by QGLPainter::setColor()
- with no lighting.
- \value FlatPerVertexColor Per-vertex flat colors specified by a
- QGL::Color vertex array with no lighting.
- \value FlatReplaceTexture2D Map a texture across the fragments with
- no lighting. The final fragment color is replaced directly
- with the texture. The texture is sourced from texture unit 0.
- \value FlatDecalTexture2D Map a texture across the fragments, combined
- with QGLPainter::color(), and no lighting. The texture is sourced
- from texture unit 0.
- \value LitMaterial Material colors specified by
- QGLPainter::setFaceMaterial() with lighting enabled. It is
- assumed that per-vertex normals are provided. Under OpenGL/ES 2.0
- only one light is supported, with single-sided materials,
- and no attenuation.
- \value LitDecalTexture2D Map a texture across the fragments, combined
- with the material color specified by QGLPainter::setFaceMaterial(),
- and lighting using the GL_DECAL combination rule. The texture is
- sourced from texture unit 0. It is assumed that per-vertex
- normals are provided. Under OpenGL/ES 2.0 only one light is
- supported, with single-sided materials, and no attenuation.
- \value LitModulateTexture2D Map a texture across the fragments, combined
- with the material color specified by QGLPainter::setFaceMaterial(),
- and lighting using the GL_MODULATE combination rule. The texture
- is sourced from texture unit 0. It is assumed that per-vertex
- normals are provided. Under OpenGL/ES 2.0 only one light is
- supported, with single-sided materials, and no attenuation.
-*/
-
-/*!
- \enum QGL::TextureWrap
- \since 4.8
- This enum defines the wrapping mode for texture co-ordinates.
-
- \value Repeat Ignore the integer part of the texture co-ordinate and
- create a repeating pattern using the texture.
- \value Clamp Clamps the texture co-ordinate to the range 0 to 1.
- This value is not supported in OpenGL/ES, where it will be
- treated the same as ClampToEdge.
- \value ClampToBorder Clamps the texture co-ordinate to the range
- (-1 / 2N) to (1 + 1 / 2N) where N is the size of the texture in
- the direction of clamping. This value is supported in OpenGL 1.3
- and higher. In OpenGL versions less than 1.3, this value will
- be treated the same as Clamp. In OpenGL/ES, this value will be
- treated the same as ClampToEdge.
- \value ClampToEdge Clamps the texture co-ordinate to the range
- (1 / 2N) to (1 - 1 / 2N) where N is the size of the texture in
- the direction of clamping. This value is supported in OpenGL 1.2
- and higher, and in all versions of OpenGL/ES. In OpenGL versions
- less than 1.2, this value will be treated the same as Clamp.
- \value MirroredRepeat If the integer part of the texture co-ordinate
- is even, then use the fractional part. If the integer part of
- the texture co-ordinate is odd, then use 1 - the fractional part.
- This creates an alternating repeating pattern from the texture.
- This value is only supported in OpenGL 1.4 and higher, or
- OpenGL/ES 2.0 and higher. On other versions, MirroredRepeat
- will be treated the same as Repeat.
-*/
-
-/*!
- \enum QGL::Eye
- \since 4.8
- This enum defines the eye that is being rendered by a QGLPainter
- when stereo rendering is in effect.
-
- \value NoEye Do not perform an eye adjustment on the camera because
- stereo rendering is not in effect.
- \value LeftEye Render the scene from the perspective of the left eye.
- \value RightEye Render the scene from the perspective of the right eye.
-*/
-
-/*!
- \enum QGL::Smoothing
- \since 4.8
- \relates QGLBuilder
-
- This enum defines vertex smoothing treatments.
- \value NoSmoothing No smoothing processing is performed.
- \value Smooth Lighting normals averaged for each face for a smooth appearance.
- \value Faceted Lighting normals separate for each face for a faceted appearance.
-*/
-
-/*!
- \enum QGL::Mouse3DKeys
- \since 4.8
- This enum defines extra key codes for QKeyEvent related to 3D mice
- devices. See QMouse3DEventProvider for further details.
-
- \value Key_Fit Reset the transform so the model is centered to
- fit within the view.
- \value Key_TopView Switch to the top view.
- \value Key_LeftView Switch to the left view.
- \value Key_RightView Switch to the right view.
- \value Key_FrontView Switch to the front view.
- \value Key_BottomView Switch to the bottom view.
- \value Key_BackView Switch to the back view.
- \value Key_RotateCW90 Rotate clockwise by 90 degrees.
- \value Key_RotateCCW90 Rotate counter-clockwise by 90 degrees.
- \value Key_ISO1 Show an isometric view of the model with top, front,
- and right sides.
- \value Key_ISO2 Show an isometric view of the model with top, back
- and left sides.
- \value Key_Button1 Special function button 1.
- \value Key_Button2 Special function button 2.
- \value Key_Button3 Special function button 3.
- \value Key_Button4 Special function button 4.
- \value Key_Button5 Special function button 5.
- \value Key_Button6 Special function button 6.
- \value Key_Button7 Special function button 7.
- \value Key_Button8 Special function button 8.
- \value Key_Button9 Special function button 9.
- \value Key_Button10 Special function button 10.
- \value Key_Rotations Toggles whether or not the rotation axes on a
- 3D mouse will be filtered.
- \value Key_Translations Toggles whether or not the translation axes
- on a 3D mouse will be filtered.
- \value Key_DominantAxis Toggles whether or not 3D mouse movements
- should be constrained to the dominant axis.
- \value Key_IncreaseSensitivity Increase the sensitivity of the mouse
- to wrist movements.
- \value Key_DecreaseSensitivity Decrease the sensitivity of the mouse
- to wrist movements.
-*/
-
-/*!
- Returns the next power of two that is greater than or
- equal to \a value. The \a value must be positive or the
- result is undefined.
-
- This is a convenience function for use with GL texture
- handling code.
-*/
-int QGL::nextPowerOfTwo(int value)
-{
- value--;
- value |= value >> 1;
- value |= value >> 2;
- value |= value >> 4;
- value |= value >> 8;
- value |= value >> 16;
- ++value;
- return value;
-}
-
-/*!
- Returns the next power of two that is greater than or
- equal to the width and height components of \a value.
-
- This is a convenience function for use with GL texture
- handling code.
-*/
-QSize QGL::nextPowerOfTwo(const QSize& value)
-{
- return QSize(nextPowerOfTwo(value.width()),
- nextPowerOfTwo(value.height()));
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/global/qglnamespace.h b/src/threed/global/qglnamespace.h
deleted file mode 100644
index 4987e87c..00000000
--- a/src/threed/global/qglnamespace.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLNAMESPACE_H
-#define QGLNAMESPACE_H
-
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QSize;
-
-namespace QGL
-{
- enum VertexAttribute {
- Position,
- Normal,
- Color,
- TextureCoord0,
- TextureCoord1,
- TextureCoord2,
- CustomVertex0,
- CustomVertex1,
- UserVertex
- };
-
- enum Face
- {
- FrontFaces = 0x0404, // GL_FRONT
- BackFaces = 0x0405, // GL_BACK
- AllFaces = 0x0408 // GL_FRONT_AND_BACK
- };
-
- enum DrawingMode
- {
- Points = 0x0000, // GL_POINTS
- Lines = 0x0001, // GL_LINES
- LineLoop = 0x0002, // GL_LINE_LOOP
- LineStrip = 0x0003, // GL_LINE_STRIP
- Triangles = 0x0004, // GL_TRIANGLES
- TriangleStrip = 0x0005, // GL_TRIANGLE_STRIP
- TriangleFan = 0x0006, // GL_TRIANGLE_FAN
- LinesAdjacency = 0x000A, // GL_LINES_ADJACENCY
- LineStripAdjacency = 0x000B, // GL_LINE_STRIP_ADJACENCY
- TrianglesAdjacency = 0x000C, // GL_TRIANGLES_ADJACENCY
- TriangleStripAdjacency = 0x000D // GL_TRIANGLE_STRIP_ADJACENCY
- };
-
- enum StandardEffect
- {
- FlatColor,
- FlatPerVertexColor,
- FlatReplaceTexture2D,
- FlatDecalTexture2D,
- LitMaterial,
- LitDecalTexture2D,
- LitModulateTexture2D
- };
-
- enum TextureWrap
- {
- Repeat = 0x2901, // GL_REPEAT
- Clamp = 0x2900, // GL_CLAMP
- ClampToBorder = 0x812D, // GL_CLAMP_TO_BORDER
- ClampToEdge = 0x812F, // GL_CLAMP_TO_EDGE
- MirroredRepeat = 0x8370 // GL_MIRRORED_REPEAT
- };
-
- enum Eye
- {
- NoEye,
- LeftEye,
- RightEye
- };
-
- enum Smoothing
- {
- NoSmoothing,
- Smooth,
- Faceted
- };
-
- enum Mouse3DKeys
- {
- Key_Fit = 0x01200002,
- Key_TopView = 0x01200003,
- Key_LeftView = 0x01200004,
- Key_RightView = 0x01200005,
- Key_FrontView = 0x01200006,
- Key_BottomView = 0x01200007,
- Key_BackView = 0x01200008,
- Key_RotateCW90 = 0x01200009,
- Key_RotateCCW90 = 0x0120000a,
- Key_ISO1 = 0x0120000b,
- Key_ISO2 = 0x0120000c,
- Key_Button1 = 0x0120000d,
- Key_Button2 = 0x0120000e,
- Key_Button3 = 0x0120000f,
- Key_Button4 = 0x01200010,
- Key_Button5 = 0x01200011,
- Key_Button6 = 0x01200012,
- Key_Button7 = 0x01200013,
- Key_Button8 = 0x01200014,
- Key_Button9 = 0x01200015,
- Key_Button10 = 0x01200016,
- Key_Rotations = 0x0120001b,
- Key_Translations = 0x0120001c,
- Key_DominantAxis = 0x0120001d,
- Key_IncreaseSensitivity = 0x0120001e,
- Key_DecreaseSensitivity = 0x0120001f
- };
-
- Q_QT3D_EXPORT int nextPowerOfTwo(int value);
- Q_QT3D_EXPORT QSize nextPowerOfTwo(const QSize& value);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/global/qt3dglobal.h b/src/threed/global/qt3dglobal.h
deleted file mode 100644
index 488e7e17..00000000
--- a/src/threed/global/qt3dglobal.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QT3DGLOBAL_H
-#define QT3DGLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-// XXX: Move to qglobal.h eventually.
-QT_LICENSED_MODULE(Qt3D)
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
-# if defined(QT_NODLL)
-# undef QT_MAKEDLL
-# undef QT_DLL
-# elif defined(QT_MAKEDLL) /* create a Qt DLL library */
-# if defined(QT_DLL)
-# undef QT_DLL
-# endif
-# if defined(QT_BUILD_QT3D_LIB)
-# define Q_QT3D_EXPORT Q_DECL_EXPORT
-# else
-# define Q_QT3D_EXPORT Q_DECL_IMPORT
-# endif
-# elif defined(QT_DLL) /* use a Qt DLL library */
-# define Q_QT3D_EXPORT Q_DECL_IMPORT
-# endif
-#endif
-#if !defined(Q_QT3D_EXPORT)
-# if defined(QT_SHARED)
-# define Q_QT3D_EXPORT Q_DECL_EXPORT
-# else
-# define Q_QT3D_EXPORT
-# endif
-#endif
-
-#endif
diff --git a/src/threed/graphicsview/graphicsview.pri b/src/threed/graphicsview/graphicsview.pri
deleted file mode 100644
index b43dbe66..00000000
--- a/src/threed/graphicsview/graphicsview.pri
+++ /dev/null
@@ -1,21 +0,0 @@
-
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- graphicsview/qglgraphicsviewportitem.h \
- graphicsview/qgraphicsbillboardtransform.h \
- graphicsview/qgraphicsembedscene.h \
- graphicsview/qgraphicsrotation3d.h \
- graphicsview/qgraphicsscale3d.h \
- graphicsview/qgraphicstransform3d.h \
- graphicsview/qgraphicstranslation3d.h
-
-SOURCES += \
- qglgraphicsviewportitem.cpp \
- qgraphicsbillboardtransform.cpp \
- qgraphicsembedscene.cpp \
- qgraphicsrotation3d.cpp \
- qgraphicsscale3d.cpp \
- qgraphicstransform3d.cpp \
- qgraphicstranslation3d.cpp
diff --git a/src/threed/graphicsview/qglgraphicsviewportitem.cpp b/src/threed/graphicsview/qglgraphicsviewportitem.cpp
deleted file mode 100644
index c99b695e..00000000
--- a/src/threed/graphicsview/qglgraphicsviewportitem.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglgraphicsviewportitem.h"
-#include "qglpainter.h"
-#include "qglsubsurface.h"
-#include <QtGui/qpainter.h>
-#include <QtGui/qgraphicsscene.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLGraphicsViewportItem
- \brief The QGLGraphicsViewportItem class provides a rectangular viewport for arbitrary OpenGL painting.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-*/
-
-class QGLGraphicsViewportItemPrivate : public QObject
-{
- Q_OBJECT
-public:
- QGLGraphicsViewportItemPrivate(QGLGraphicsViewportItem *item)
- : q(item)
- {
- defaultCamera = camera = new QGLCamera(this);
- connect(camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- connect(camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
- }
-
- void changeCamera(QGLCamera *c);
- void setDefaults(QGLPainter *painter);
-
- QGLGraphicsViewportItem *q;
- QRectF rect;
- QGLCamera *camera;
- QGLCamera *defaultCamera;
- QColor backgroundColor;
-
-private Q_SLOTS:
- void cameraChanged();
-};
-
-void QGLGraphicsViewportItemPrivate::changeCamera(QGLCamera *c)
-{
- disconnect(camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- disconnect(camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
- camera = c;
- connect(camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- connect(camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
-}
-
-void QGLGraphicsViewportItemPrivate::cameraChanged()
-{
- q->update();
-}
-
-void QGLGraphicsViewportItemPrivate::setDefaults(QGLPainter *painter)
-{
- // Set the default depth buffer options.
- glDepthFunc(GL_LESS);
- glDepthMask(GL_TRUE);
-#if defined(QT_OPENGL_ES)
- glDepthRangef(0.0f, 1.0f);
-#else
- glDepthRange(0.0f, 1.0f);
-#endif
-
- // Set the default blend options.
- glDisable(GL_BLEND);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter->glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter->glBlendEquation(GL_FUNC_ADD);
- else if (painter->hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter->glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
-}
-
-/*!
- Constructs a new GL graphics viewport and attaches it to \a parent.
-*/
-QGLGraphicsViewportItem::QGLGraphicsViewportItem(QGraphicsItem *parent)
- : QGraphicsItem(parent), d_ptr(new QGLGraphicsViewportItemPrivate(this))
-{
-}
-
-/*!
- Constructs a new GL graphics viewport and attaches it to \a parent.
- The boundingRect() is initially set to \a rect.
-*/
-QGLGraphicsViewportItem::QGLGraphicsViewportItem(const QRectF& rect, QGraphicsItem *parent)
- : QGraphicsItem(parent), d_ptr(new QGLGraphicsViewportItemPrivate(this))
-{
- d_ptr->rect = rect;
-}
-
-/*!
- Constructs a new GL graphics viewport and attaches it to \a parent.
- The boundingRect() is initially set to (\a x, \a y, \a w, \a h).
-*/
-QGLGraphicsViewportItem::QGLGraphicsViewportItem
- (qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent)
- : QGraphicsItem(parent), d_ptr(new QGLGraphicsViewportItemPrivate(this))
-{
- d_ptr->rect = QRectF(x, y, w, h);
-}
-
-/*!
- Destroys this GL graphics viewport.
-*/
-QGLGraphicsViewportItem::~QGLGraphicsViewportItem()
-{
-}
-
-/*!
- Returns the rectangular area of the view that is occupied by
- this GL graphics viewport.
-
- \sa setRect(), boundingRect()
-*/
-QRectF QGLGraphicsViewportItem::rect() const
-{
- Q_D(const QGLGraphicsViewportItem);
- return d->rect;
-}
-
-/*!
- Sets the rectangular area of the view that is occupied by
- this GL graphics viewport to \a rect.
-
- \sa rect(), boundingRect()
-*/
-void QGLGraphicsViewportItem::setRect(const QRectF &rect)
-{
- Q_D(QGLGraphicsViewportItem);
- if (d->rect == rect)
- return;
- prepareGeometryChange();
- d->rect = rect;
- update();
-}
-
-/*!
- \fn void QGLGraphicsViewportItem::setRect(qreal x, qreal y, qreal w, qreal h)
- \overload
-
- Sets the rectangular area of the view that is occupied by
- this GL graphics viewport to (\a x, \a y, \a w, \a h).
-
- \sa rect(), boundingRect()
-*/
-
-/*!
- Returns the bounding rectangle for this GL graphics viewport,
- which is the same as rect().
-
- \sa rect()
-*/
-QRectF QGLGraphicsViewportItem::boundingRect() const
-{
- Q_D(const QGLGraphicsViewportItem);
- return d->rect;
-}
-
-/*!
- Returns the camera parameters. The camera defines the projection
- to apply to convert eye co-ordinates into window co-ordinates,
- and the position and orientation of the viewer's eye.
-
- This item will be updated whenever the camera's parameters change.
-
- \sa setCamera()
-*/
-QGLCamera *QGLGraphicsViewportItem::camera() const
-{
- Q_D(const QGLGraphicsViewportItem);
- return d->camera;
-}
-
-/*!
- Sets the camera parameters to \a camera. The camera defines the
- projection to apply to convert eye co-ordinates into window
- co-ordinates, and the position and orientation of the viewer's eye.
-
- If \a camera is null, then the default camera object will be used.
-
- This function will call update() to force the viewport to update
- with the new camera parameters upon the next event loop. Afterwards,
- this item will be updated whenever the camera's parameters change.
-
- \sa camera()
-*/
-void QGLGraphicsViewportItem::setCamera(QGLCamera *camera)
-{
- Q_D(QGLGraphicsViewportItem);
- if (!camera)
- camera = d->defaultCamera;
- if (d->camera != camera) {
- d->changeCamera(camera);
- update();
- }
-}
-
-/*!
- Returns the background color, which is used to clear the viewport
- before calling paintGL(). The default value is an invalid QColor,
- which indicates that the viewport should not be cleared.
-
- \sa setBackgroundColor()
-*/
-QColor QGLGraphicsViewportItem::backgroundColor() const
-{
- Q_D(const QGLGraphicsViewportItem);
- return d->backgroundColor;
-}
-
-/*!
- Sets the background \a color, which is used to clear the viewport
- before calling paintGL().
-
- \sa backgroundColor()
-*/
-void QGLGraphicsViewportItem::setBackgroundColor(const QColor& color)
-{
- Q_D(QGLGraphicsViewportItem);
- d->backgroundColor = color;
-}
-
-/*!
- Paints this GL graphics viewport onto \a painter, with the specified
- \a option and \a widget parameters.
-
- This override creates a QGLPainter for \a painter and passes
- it to paintGL().
-
- \sa paintGL()
-*/
-void QGLGraphicsViewportItem::paint
- (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_D(QGLGraphicsViewportItem);
-
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- if (d->rect.isEmpty())
- return;
-
- // Initialize a QGLPainter for the surface and bail out if not active.
- QGLPainter glpainter;
- if (!glpainter.begin(painter)) {
- qWarning("GL graphics system is not active; cannot use 3D items");
- return;
- }
-
- // Set up the GL viewport to limit drawing to the bounds of this item.
- QRect viewport = painter->deviceTransform().mapRect(rect()).toRect();
- QGLSubsurface surface(glpainter.currentSurface(), viewport);
- glpainter.pushSurface(&surface);
-
- // Set up the desired drawing options.
- glDisable(GL_CULL_FACE);
- d->setDefaults(&glpainter);
- if (d->backgroundColor.isValid()) {
- // We clear the background by drawing a triangle fan so
- // that the background color will blend with the underlying
- // screen content if it has an alpha component.
- glDisable(GL_DEPTH_TEST);
- if (d->backgroundColor.alpha() != 255)
- glEnable(GL_BLEND);
- else
- glDisable(GL_BLEND);
- QVector2DArray array;
- array.append(-1, -1);
- array.append(1, -1);
- array.append(1, 1);
- array.append(-1, 1);
- glpainter.projectionMatrix().setToIdentity();
- glpainter.modelViewMatrix().setToIdentity();
- glpainter.setStandardEffect(QGL::FlatColor);
- glpainter.setColor(d->backgroundColor);
- glpainter.setVertexAttribute(QGL::Position, array);
- glpainter.draw(QGL::TriangleFan, 4);
- }
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
-
- // Apply the camera.
- glpainter.setEye(QGL::NoEye);
- glpainter.setCamera(d->camera);
-
- // Paint the GL contents.
- paintGL(&glpainter);
-
- // Disable the current drawing effect so that QGLPainter will
- // forcibly update the GL context the next time QGLPainter is used.
- glpainter.disableEffect();
-
- // Try to restore the GL state to something paint-engine compatible.
- glDisable(GL_CULL_FACE);
- d->setDefaults(&glpainter);
- glDisable(GL_DEPTH_TEST);
-
- glpainter.popSurface();
-}
-
-/*!
- \fn void QGLGraphicsViewportItem::paintGL(QGLPainter *painter)
-
- Paints this GL graphics viewport onto \a painter. This function is called
- from paint().
-
- \sa paint()
-*/
-
-QT_END_NAMESPACE
-
-#include "qglgraphicsviewportitem.moc"
diff --git a/src/threed/graphicsview/qglgraphicsviewportitem.h b/src/threed/graphicsview/qglgraphicsviewportitem.h
deleted file mode 100644
index b7b10364..00000000
--- a/src/threed/graphicsview/qglgraphicsviewportitem.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLGRAPHICSVIEWPORTITEM_H
-#define QGLGRAPHICSVIEWPORTITEM_H
-
-#include "qglnamespace.h"
-#include <QtGui/qgraphicsitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLGraphicsViewportItemPrivate;
-class QGLPainter;
-class QGLCamera;
-
-class Q_QT3D_EXPORT QGLGraphicsViewportItem : public QGraphicsItem
-{
-public:
- QGLGraphicsViewportItem(QGraphicsItem *parent = 0);
- QGLGraphicsViewportItem(const QRectF& rect, QGraphicsItem *parent = 0);
- QGLGraphicsViewportItem(qreal x, qreal y, qreal w, qreal h,
- QGraphicsItem *parent = 0);
- ~QGLGraphicsViewportItem();
-
- QRectF rect() const;
- void setRect(const QRectF &rect);
- inline void setRect(qreal x, qreal y, qreal w, qreal h);
-
- QRectF boundingRect() const;
-
- QGLCamera *camera() const;
- void setCamera(QGLCamera *camera);
-
- QColor backgroundColor() const;
- void setBackgroundColor(const QColor& color);
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-
-protected:
- virtual void paintGL(QGLPainter *painter) = 0;
-
-private:
- QScopedPointer<QGLGraphicsViewportItemPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLGraphicsViewportItem)
- Q_DISABLE_COPY(QGLGraphicsViewportItem)
-};
-
-void QGLGraphicsViewportItem::setRect(qreal x, qreal y, qreal w, qreal h)
-{
- setRect(QRectF(x, y, w, h));
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicsbillboardtransform.cpp b/src/threed/graphicsview/qgraphicsbillboardtransform.cpp
deleted file mode 100644
index 449d9172..00000000
--- a/src/threed/graphicsview/qgraphicsbillboardtransform.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicsbillboardtransform.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsBillboardTransform
- \brief The QGraphicsBillboardTransform class implements a transformation that causes objects to face the camera.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- Sometimes it can be useful to make an object face towards the camera
- no matter what orientation the scene is in. The common name for
- this technique is "billboarding".
-
- When applied as a transformation, this class will replace the top-left
- 3x3 part of the transformation matrix with the identity. This has the
- effect of removing the rotation and scale components from the current
- world co-ordinate orientation.
-*/
-
-/*!
- \qmlclass BillboardTransform QGraphicsBillboardTransform
- \brief The BillboardTransform item implements a transformation that causes objects to face the camera.
- \since 4.8
- \ingroup qt3d::qml3d
-
- Sometimes it can be useful to make an object face towards the camera
- no matter what orientation the scene is in. The common name for
- this technique is "billboarding".
-
- When applied as a transformation, this class will replace the top-left
- 3x3 part of the transformation matrix with the identity. This has the
- effect of removing the rotation and scale components from the current
- world co-ordinate orientation. In QML, this can be used as follows
- to orient a pane to point towards the viewer:
-
- \code
- Item3D {
- mesh: Mesh { source: "pane.obj" }
- position: Qt.vector3d(2, 0, -20)
- transform: BillboardTransform {}
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-
- Because the billboard transformation will strip any further
- alterations to the matrix, it will usually be the last element
- in the \c transform list (transformations are applied to the matrix in
- reverse order of their appearance in \c transform):
-
- \code
- Item3D {
- mesh: Mesh { source: "pane.obj" }
- position: Qt.vector3d(2, 0, -20)
- transform: [
- Scale3D { scale: 0.5 },
- Rotation3D { angle: 30 },
- BillboardTransform {}
- ]
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-
- The \c scale property is applied to the matrix after \c transform has
- performed the billboard transformation, so the above can also be written
- as follows:
-
- \code
- Item3D {
- mesh: Mesh { source: "pane.obj" }
- position: Qt.vector3d(2, 0, -20)
- scale: 0.5
- transform: [
- Rotation3D { angle: 30 },
- BillboardTransform {}
- ]
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-
- By default the billboard transform will cause the object to
- face directly at the camera no matter how the world co-ordinate
- system is rotated. Sometimes the billboard needs to stay at right
- angles to the "ground plane" even if the user's viewpoint is
- elevated. This behavior can be enabled using the preserveUpVector
- property:
-
- \code
- Pane {
- position: Qt.vector3d(2, 0, -20)
- transform: BillboardTransform { preserveUpVector: true }
- effect: Effect { texture: "picture.jpg" }
- }
- \endcode
-*/
-
-class QGraphicsBillboardTransformPrivate
-{
-public:
- QGraphicsBillboardTransformPrivate() : preserveUpVector(false) {}
-
- bool preserveUpVector;
-};
-
-/*!
- Construct a billboard transform and attach it to \a parent.
-*/
-QGraphicsBillboardTransform::QGraphicsBillboardTransform(QObject *parent)
- : QGraphicsTransform3D(parent), d_ptr(new QGraphicsBillboardTransformPrivate)
-{
-}
-
-/*!
- Destroy this billboard transform.
-*/
-QGraphicsBillboardTransform::~QGraphicsBillboardTransform()
-{
-}
-
-/*!
- \property QGraphicsBillboardTransform::preserveUpVector
- \brief true to preserve the up orientation.
-
- The default value for this property is false, which indicates that
- the object being transformed should always face directly to the camera
- This is also known as a "spherical billboard".
-
- If the value for this property is true, then the object will have
- its up orientation preserved. This is also known as a "cylindrical
- billboard".
-*/
-
-/*!
- \qmlproperty bool BillboardTransform::preserveUpVector
-
- This property specifies whether the billboard transform should
- preserve the "up vector" so that objects stay at right angles
- to the ground plane in the scene.
-
- The default value for this property is false, which indicates that
- the object being transformed should always face directly to the camera
- This is also known as a "spherical billboard".
-
- If the value for this property is true, then the object will have
- its up orientation preserved. This is also known as a "cylindrical
- billboard".
-*/
-
-bool QGraphicsBillboardTransform::preserveUpVector() const
-{
- Q_D(const QGraphicsBillboardTransform);
- return d->preserveUpVector;
-}
-
-void QGraphicsBillboardTransform::setPreserveUpVector(bool value)
-{
- Q_D(QGraphicsBillboardTransform);
- if (d->preserveUpVector != value) {
- d->preserveUpVector = value;
- emit transformChanged();
- emit preserveUpVectorChanged();
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsBillboardTransform::applyTo(QMatrix4x4 *matrix) const
-{
- Q_D(const QGraphicsBillboardTransform);
- if (!d->preserveUpVector) {
- // Replace the top-left 3x3 of the matrix with the identity.
- // The technique is "Cheating Spherical Billboards", described here:
- // http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat
- (*matrix)(0, 0) = 1.0f;
- (*matrix)(0, 1) = 0.0f;
- (*matrix)(0, 2) = 0.0f;
- (*matrix)(1, 0) = 0.0f;
- (*matrix)(1, 1) = 1.0f;
- (*matrix)(1, 2) = 0.0f;
- (*matrix)(2, 0) = 0.0f;
- (*matrix)(2, 1) = 0.0f;
- (*matrix)(2, 2) = 1.0f;
- } else {
- // Replace some of the top-left 3x3 of the matrix with the identity,
- // but leave the up vector component in the second column as-is.
- // The technique is "Cheating Cylindrical Billboards", described here:
- // http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat1
- (*matrix)(0, 0) = 1.0f;
- (*matrix)(0, 2) = 0.0f;
- (*matrix)(1, 0) = 0.0f;
- (*matrix)(1, 2) = 0.0f;
- (*matrix)(2, 0) = 0.0f;
- (*matrix)(2, 2) = 1.0f;
- }
- matrix->optimize();
-}
-
-/*!
- \internal
-*/
-QGraphicsTransform3D *QGraphicsBillboardTransform::clone(QObject *parent) const
-{
- Q_D(const QGraphicsBillboardTransform);
- QGraphicsBillboardTransform *copy = new QGraphicsBillboardTransform(parent);
- copy->setPreserveUpVector(d->preserveUpVector);
- return copy;
-}
-
-/*!
- \fn void QGraphicsBillboardTransform::preserveUpVectorChanged()
-
- Signal that is emitted when preserveUpVector() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/graphicsview/qgraphicsbillboardtransform.h b/src/threed/graphicsview/qgraphicsbillboardtransform.h
deleted file mode 100644
index 61ec4072..00000000
--- a/src/threed/graphicsview/qgraphicsbillboardtransform.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSBILLBOARDTRANSFORM_H
-#define QGRAPHICSBILLBOARDTRANSFORM_H
-
-#include "qgraphicstransform3d.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsBillboardTransformPrivate;
-
-class Q_QT3D_EXPORT QGraphicsBillboardTransform : public QGraphicsTransform3D
-{
- Q_OBJECT
- Q_PROPERTY(bool preserveUpVector READ preserveUpVector WRITE setPreserveUpVector NOTIFY preserveUpVectorChanged)
-public:
- QGraphicsBillboardTransform(QObject *parent = 0);
- ~QGraphicsBillboardTransform();
-
- bool preserveUpVector() const;
- void setPreserveUpVector(bool value);
-
- void applyTo(QMatrix4x4 *matrix) const;
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-Q_SIGNALS:
- void preserveUpVectorChanged();
-
-private:
- QScopedPointer<QGraphicsBillboardTransformPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGraphicsBillboardTransform)
- Q_DECLARE_PRIVATE(QGraphicsBillboardTransform)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicsembedscene.cpp b/src/threed/graphicsview/qgraphicsembedscene.cpp
deleted file mode 100644
index 9e245880..00000000
--- a/src/threed/graphicsview/qgraphicsembedscene.cpp
+++ /dev/null
@@ -1,469 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicsembedscene.h"
-#include "qglnamespace.h"
-#include <QtOpenGL/qglframebufferobject.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsEmbedScene
- \brief The QGraphicsEmbedScene class provides a method to render a QGraphicsScene into a texture.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- \section1 Rendering the scene into a texture
-
- Embedded scenes are rendered into textures with renderToTexture()
- before the main 3D scene painting with QGLPainter starts. The following
- example shows the sequence of operations for a QGLWidget:
-
- \code
- void MyGLWidget::paintGL()
- {
- GLuint textureId = scene.renderToTexture();
-
- QGLPainter painter(this);
- painter.glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, textureId);
- ... // draw the 3D object
- painter.glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- \endcode
-
- When using QGLView, override the QGLWidget::paintGL() function
- explicitly to render scenes into textures before QGLView::paintGL()
- is called:
-
- \code
- void MyGLView::paintGL()
- {
- textureId = scene.renderToTexture();
- QGLView::paintGL();
- }
-
- void MyGLView::paintGL(QGLPainter *painter)
- {
- painter->glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, textureId);
- ... // draw the 3D object
- painter->glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- \endcode
-
- The texture is oriented so that (0, 0) corresponds to the bottom-left
- of the scene, and (1, 1) corresponds to the top-right of the scene.
- The texture may be scaled up to a power of two in size for better
- performance.
-
- \section1 Delivering mouse and keyboard events
-
- Mouse and keyboard events originate with the widget that is
- displaying the 3D scene. The application needs to intercept
- these events and decide which 3D object in the scene should
- get the event.
-
- The application then performs an intersection between the 3D
- object and a line in 3D space (usually a QRay3D) to determine
- the texture co-ordinate of where the user clicked on the object.
- How the intersection is determined is application-specific; different
- algorithms are needed based on the type of object (cube, sphere,
- parameterized mesh, etc).
-
- Once the texture co-ordinate has been determined, the application
- passes the widget event and the texture co-ordinate to deliverEvent().
- QGraphicsEmbedScene will then route the event to the appropriate
- graphics item in the embedded scene.
-
- Keyboard, focus in/out, and other non-mouse events do not need a
- texture co-ordinate. Pass (0, 0) as the texture co-ordinate for
- those event types.
-
- \section1 Updating the 3D scene
-
- The application will probably want to perform an update() whenever
- something changes in the embedded scene. The application should
- listen for the QGraphicsScene::changed() and
- QGraphicsScene::sceneRectChanged() signals.
-
- \section1 Performance notes
-
- QGraphicsEmbedScene renders the scene into a framebuffer object,
- which will involve GL state switching. The scene will be
- effectively triple-buffered: render into the fbo, then render
- the fbo into the GL window's back buffer, and finally copy to the
- GL window's front buffer.
-
- If the scene is showing a video item or something else that is
- highly animated, then it may be better to render the source into a
- texture some other way.
-
- If the embedded scene is itself a 3D scene drawn with GL, then use
- QGLPainter::pushSurface() and a QGLFramebufferObjectSurface instead
- of QGraphicsEmbedScene.
-
- \section1 Limitations
-
- When rendered into a texture, the scene does not have a QGraphicsView
- or a viewport QWidget associated with it. Graphics items that require a
- widget rendering surface will not work correctly.
-*/
-
-class QGraphicsEmbedScenePrivate : public QObject
-{
- Q_OBJECT
-public:
- QGraphicsEmbedScenePrivate(QGraphicsScene *scene, QObject *parent = 0)
- : QObject(parent)
- , dirty(true)
- , fbo(0)
- {
- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
-
- connect(scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(update()));
- connect(scene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(update()));
- }
- ~QGraphicsEmbedScenePrivate()
- {
- delete fbo;
- }
-
- bool dirty;
- QGLFramebufferObject *fbo;
- QGLFramebufferObjectFormat format;
- QPoint pressedPos;
-
-public Q_SLOTS:
- void update() { dirty = true; }
-};
-
-/*!
- Constructs an embedded graphics scene and attaches it to \a parent.
-*/
-QGraphicsEmbedScene::QGraphicsEmbedScene(QObject *parent)
- : QGraphicsScene(parent)
- , d_ptr(new QGraphicsEmbedScenePrivate(this))
-{
-}
-
-/*!
- Constructs an embedded graphics scene, using \a sceneRect for its
- scene rectangle, and attaches it to \a parent.
-*/
-QGraphicsEmbedScene::QGraphicsEmbedScene(const QRectF &sceneRect, QObject *parent)
- : QGraphicsScene(sceneRect, parent)
- , d_ptr(new QGraphicsEmbedScenePrivate(this))
-{
-}
-
-/*!
- Constructs an embedded graphics scene, using (\a x, \a y, \a width,
- \a height) for its scene rectangle, and attaches it to \a parent.
-*/
-QGraphicsEmbedScene::QGraphicsEmbedScene(qreal x, qreal y, qreal width, qreal height, QObject *parent)
- : QGraphicsScene(x, y, width, height, parent)
- , d_ptr(new QGraphicsEmbedScenePrivate(this))
-{
-}
-
-/*!
- Destroys this embedded graphics scene.
-*/
-QGraphicsEmbedScene::~QGraphicsEmbedScene()
-{
-}
-
-/*!
- Returns the framebuffer object format to use when renderToTexture()
- is called. The default is a framebuffer format with depth and
- stencil buffers, RGBA format, and no multisampling.
-
- \sa setFormat()
-*/
-QGLFramebufferObjectFormat QGraphicsEmbedScene::format() const
-{
- Q_D(const QGraphicsEmbedScene);
- return d->format;
-}
-
-/*!
- Sets the framebuffer object \a format to use when renderToTexture()
- is called.
-
- \sa format()
-*/
-void QGraphicsEmbedScene::setFormat(const QGLFramebufferObjectFormat &format)
-{
- Q_D(QGraphicsEmbedScene);
- d->format = format;
-}
-
-/*!
- Renders this scene to a GL texture and returns the texture identifier.
- If the scene has not changed since the last call, then the same
- texture identifier will be returned without repainting the scene.
-
- The \a levelOfDetail is a hint that allows some control over the
- texture size. The default value of 1 indicates that the texture size
- should be the same or similar to the size of the scene. A value of 2
- would indicate that the texture size should have twice the width and
- height. A value of 0.5 would indicate half the size.
-
- The primary use for \a levelOfDetail is to render the scene with a
- greater level of detail when the 3D object showing the texture is
- larger on-screen than the scene's natural size. The parameter can
- also be used to reduce the level of detail in the texture when the
- 3D object is very small.
-
- It is assumed that a QGLContext is bound when this function is
- called. Usually this is the QGLContext that is bound by a QPainter
- for 2D painting into a GL surface. Note however that a QGLPainter must
- not be active on the QGLContext when this function is called.
-
- \sa format()
-*/
-GLuint QGraphicsEmbedScene::renderToTexture(qreal levelOfDetail)
-{
- Q_D(QGraphicsEmbedScene);
-
- // Determine the fbo size we will need.
- QSize size = (sceneRect().size() * levelOfDetail).toSize();
- QSize fboSize = QGL::nextPowerOfTwo(size);
- if (fboSize.isEmpty())
- fboSize = QSize(16, 16);
-
- // Create or re-create the fbo.
- if (!d->fbo || d->fbo->size() != fboSize) {
- delete d->fbo;
- d->fbo = new QGLFramebufferObject(fboSize, d->format);
- if (!d->fbo->isValid()) {
- delete d->fbo;
- d->fbo = 0;
- return 0;
- }
- d->dirty = true;
- }
-
- // Return the previous texture contents if the scene hasn't changed.
- if (!d->dirty && d->fbo)
- return d->fbo->texture();
-
- // Render the scene into the fbo, scaling the QPainter's view
- // transform up to the power-of-two fbo size.
- QPainter painter(d->fbo);
- painter.setWindow(0, 0, size.width(), size.height());
- painter.setViewport(0, 0, fboSize.width(), fboSize.height());
- render(&painter);
- painter.end();
- d->dirty = false;
- return d->fbo->texture();
-}
-
-/*!
- Delivers \a event to this scene. If \a event is a mouse event, then
- \a texCoord indicates the texture co-ordinate on the side of the
- 3D object where the user clicked. This \a texCoord is used to determine
- the actual scene co-ordinate to deliver: (0, 0) corresponds to the
- bottom-left corner of the scene and (1, 1) corresponds to the
- top-right corner of the scene.
-
- The \a event normally originates from a QWidget or QGraphicsItem that
- contains the 3D object. The caller performs a ray intersection in
- 3D space on the position within \a event to determine the \a texCoord
- and then passes \a event on to deliverEvent() for further processing.
-*/
-void QGraphicsEmbedScene::deliverEvent(QEvent *event, const QPointF &texCoord)
-{
- Q_D(QGraphicsEmbedScene);
-
- // Map the texture co-ordinate into "screen" co-ordinates.
- // Mouse move and release events can extend beyond the boundaries
- // of the scene, for "click and drag off-screen" operations.
- // Mouse press and double-click events need to be constrained.
- QRectF bounds = sceneRect();
- int screenX = qRound(texCoord.x() * bounds.width());
- int screenY = qRound((1.0f - texCoord.y()) * bounds.height());
- switch (event->type()) {
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonDblClick:
- if (screenX < 0)
- screenX = 0;
- else if (screenX >= bounds.width())
- screenX = qRound(bounds.width() - 1);
- if (screenY < 0)
- screenY = 0;
- else if (screenY >= bounds.height())
- screenY = qRound(bounds.height() - 1);
- d->pressedPos = QPoint(screenX, screenY);
- break;
- default: break;
- }
-
- // Convert the event and deliver it to the scene.
- switch (event->type()) {
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick: {
- QGraphicsSceneMouseEvent *ev =
- static_cast<QGraphicsSceneMouseEvent *>(event);
- QGraphicsSceneMouseEvent e(ev->type());
- e.setPos(QPointF(screenX, screenY));
- e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
- e.setScreenPos(QPoint(screenX, screenY));
- e.setButtonDownScreenPos(ev->button(), d->pressedPos);
- e.setButtonDownScenePos
- (ev->button(), QPointF(d->pressedPos.x() + bounds.x(),
- d->pressedPos.y() + bounds.y()));
- e.setButtons(ev->buttons());
- e.setButton(ev->button());
- e.setModifiers(ev->modifiers());
- e.setAccepted(false);
- QApplication::sendEvent(this, &e);
- }
- break;
-
-#ifndef QT_NO_WHEELEVENT
- case QEvent::GraphicsSceneWheel: {
- QGraphicsSceneWheelEvent *ev =
- static_cast<QGraphicsSceneWheelEvent *>(event);
- QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel);
- e.setPos(QPointF(screenX, screenY));
- e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
- e.setScreenPos(QPoint(screenX, screenY));
- e.setButtons(ev->buttons());
- e.setModifiers(ev->modifiers());
- e.setDelta(ev->delta());
- e.setOrientation(ev->orientation());
- e.setAccepted(false);
- QApplication::sendEvent(this, &e);
- }
- break;
-#endif
-
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove: {
- QMouseEvent *ev = static_cast<QMouseEvent *>(event);
- QEvent::Type type;
- if (ev->type() == QEvent::MouseButtonPress)
- type = QEvent::GraphicsSceneMousePress;
- else if (ev->type() == QEvent::MouseButtonRelease)
- type = QEvent::GraphicsSceneMouseRelease;
- else if (ev->type() == QEvent::MouseButtonDblClick)
- type = QEvent::GraphicsSceneMouseDoubleClick;
- else
- type = QEvent::GraphicsSceneMouseMove;
- QGraphicsSceneMouseEvent e(type);
- e.setPos(QPointF(screenX, screenY));
- e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
- e.setScreenPos(QPoint(screenX, screenY));
- e.setButtonDownScreenPos(ev->button(), d->pressedPos);
- e.setButtonDownScenePos
- (ev->button(), QPointF(d->pressedPos.x() + bounds.x(),
- d->pressedPos.y() + bounds.y()));
- e.setButtons(ev->buttons());
- e.setButton(ev->button());
- e.setModifiers(ev->modifiers());
- e.setAccepted(false);
- QApplication::sendEvent(this, &e);
- }
- break;
-
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel: {
- QWheelEvent *ev = static_cast<QWheelEvent *>(event);
- QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel);
- e.setPos(QPointF(screenX, screenY));
- e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
- e.setScreenPos(QPoint(screenX, screenY));
- e.setButtons(ev->buttons());
- e.setModifiers(ev->modifiers());
- e.setDelta(ev->delta());
- e.setOrientation(ev->orientation());
- e.setAccepted(false);
- QApplication::sendEvent(this, &e);
- }
- break;
-#endif
-
- default: {
- // Send the event directly without any conversion.
- // Typically used for keyboard, focus, and enter/leave events.
- QApplication::sendEvent(this, event);
- }
- break;
-
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsEmbedScene::drawBackground(QPainter *painter, const QRectF &rect)
-{
- if (backgroundBrush().style() == Qt::NoBrush) {
- // Fill the fbo with the transparent color as there won't
- // be a window or graphics item drawing a previous background.
- painter->save();
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- painter->fillRect(rect, Qt::transparent);
- painter->restore();
- } else {
- QGraphicsScene::drawBackground(painter, rect);
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qgraphicsembedscene.moc"
diff --git a/src/threed/graphicsview/qgraphicsembedscene.h b/src/threed/graphicsview/qgraphicsembedscene.h
deleted file mode 100644
index 30504aea..00000000
--- a/src/threed/graphicsview/qgraphicsembedscene.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSEMBEDSCENE_H
-#define QGRAPHICSEMBEDSCENE_H
-
-#include "qglnamespace.h"
-#include <QtGui/qgraphicsscene.h>
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGraphicsEmbedScenePrivate;
-class QGLFramebufferObjectFormat;
-
-class Q_QT3D_EXPORT QGraphicsEmbedScene : public QGraphicsScene
-{
- Q_OBJECT
-public:
- QGraphicsEmbedScene(QObject *parent = 0);
- QGraphicsEmbedScene(const QRectF &sceneRect, QObject *parent = 0);
- QGraphicsEmbedScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0);
- virtual ~QGraphicsEmbedScene();
-
- QGLFramebufferObjectFormat format() const;
- void setFormat(const QGLFramebufferObjectFormat &format);
-
- GLuint renderToTexture(qreal levelOfDetail = 1.0f);
-
- void deliverEvent(QEvent *event, const QPointF &texCoord);
-
-protected:
- void drawBackground(QPainter *painter, const QRectF &rect);
-
-private:
- QScopedPointer<QGraphicsEmbedScenePrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGraphicsEmbedScene)
- Q_DISABLE_COPY(QGraphicsEmbedScene)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicsrotation3d.cpp b/src/threed/graphicsview/qgraphicsrotation3d.cpp
deleted file mode 100644
index d23e2936..00000000
--- a/src/threed/graphicsview/qgraphicsrotation3d.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicsrotation3d.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsRotation3D
- \brief The QGraphicsRotation3D class supports arbitrary rotation around an axis in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- \sa QGraphicsTranslation3D, QGraphicsScale3D
-*/
-
-/*!
- \qmlclass Rotation3D QGraphicsRotation3D
- \brief The Rotation3D item supports arbitrary rotation around an axis in 3D space.
- \since 4.8
- \ingroup qt3d::qml3d
-
- Frequently a user will create and item in the 3d world and immediately
- wish to apply a rotation to that item before it is displayed, or,
- optionally, perform an animation on that rotation parameter based on
- user inputs, or other events. Such an rotation can easily be defined
- in QML using the following code:
-
- \code
- Item3D {
- id: helicoptor
- mesh: Mesh {source: "monkey.3ds"}
- effect: Effect {}
- cullFaces: "CullBackFaces"
-
- transform: [
- Rotation3D {
- id: rotate1
- angle: 5
- axis: Qt.vector3d(1, 0, 0)
- },
- Rotation3D {
- id: rotate2
- angle: 5
- axis: Qt.vector3d(0, 1, 0)
- },
- Rotation3D {
- id: rotate3
- angle: 45
- axis: Qt.vector3d(0, 0, 1)
- }
- ]
-
- SequentialAnimation {
- NumberAnimation {target: rotate1; property: "angle"; to : 360.0; duration: 3000; easing.type:easeOutQuad }
- }
- }
- \endcode
-
- Notice here that we create a list of rotations for the \c transform
- property of the container item. By doing this we allow rotations
- around each of the axes individually in a manner which is conducive
- to animation and interaction.
-
- Each of the rotations has an \c axis property which is a QVector3D.
- This vector contains a value for each of the three components
- corresponding to x, y, and z. In the above example, we first
- rotate by 5 degrees about the x axis, then 5 degrees about the y
- axis, and finally by 45 degrees about the z axis.
-
- By giving each rotation a unique \c id users can then refer to these
- rotations in the QML source in order to perform rotational animations.
-
- \sa Translation3D, Scale3D
-*/
-
-class QGraphicsRotation3DPrivate
-{
-public:
- QGraphicsRotation3DPrivate() : axis(0, 0, 1), angle(0) {}
-
- QVector3D origin;
- QVector3D axis;
- qreal angle;
-};
-
-/*!
- Create a 3D rotation transformation and attach it to \a parent.
-*/
-QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent)
- : QGraphicsTransform3D(parent)
- , d_ptr(new QGraphicsRotation3DPrivate)
-{
-}
-
-/*!
- Destroy this 3D rotation transformation.
-*/
-QGraphicsRotation3D::~QGraphicsRotation3D()
-{
-}
-
-/*!
- \property QGraphicsRotation3D::origin
- \brief the origin about which to rotate.
-
- The default value for this property is (0, 0, 0).
-*/
-
-/*!
- \qmlproperty vector3D Rotation3D::origin
-
- The origin about which to rotate. The default value for this
- property is (0, 0, 0).
-*/
-
-QVector3D QGraphicsRotation3D::origin() const
-{
- Q_D(const QGraphicsRotation3D);
- return d->origin;
-}
-
-void QGraphicsRotation3D::setOrigin(const QVector3D &value)
-{
- Q_D(QGraphicsRotation3D);
- if (d->origin != value) {
- d->origin = value;
- emit transformChanged();
- emit originChanged();
- }
-}
-
-/*!
- \property QGraphicsRotation3D::angle
- \brief the angle to rotate around the axis, in degrees anti-clockwise.
-
- The default value for this property is 0.
-*/
-
-/*!
- \qmlproperty real Rotation3D::angle
-
- The angle to rotate around the axis, in degrees anti-clockwise.
- The default value for this property is 0.
-*/
-
-qreal QGraphicsRotation3D::angle() const
-{
- Q_D(const QGraphicsRotation3D);
- return d->angle;
-}
-
-void QGraphicsRotation3D::setAngle(qreal value)
-{
- Q_D(QGraphicsRotation3D);
- if (d->angle != value) {
- d->angle = value;
- emit transformChanged();
- emit angleChanged();
- }
-}
-
-/*!
- \property QGraphicsRotation3D::axis
- \brief the axis to rotate around.
-
- The default value for this property is (0, 0, 1); i.e. the z-axis.
-*/
-
-/*!
- \qmlproperty vector3D Rotation3D::axis
-
- The axis to rotate around. The default value for this property
- is (0, 0, 1); i.e. the z-axis.
-*/
-
-QVector3D QGraphicsRotation3D::axis() const
-{
- Q_D(const QGraphicsRotation3D);
- return d->axis;
-}
-
-void QGraphicsRotation3D::setAxis(const QVector3D &value)
-{
- Q_D(QGraphicsRotation3D);
- if (d->axis != value) {
- d->axis = value;
- emit transformChanged();
- emit axisChanged();
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsRotation3D::applyTo(QMatrix4x4 *matrix) const
-{
- Q_D(const QGraphicsRotation3D);
- matrix->translate(d->origin);
- matrix->rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
- matrix->translate(-d->origin);
-}
-
-/*!
- \internal
-*/
-QGraphicsTransform3D *QGraphicsRotation3D::clone(QObject *parent) const
-{
- Q_D(const QGraphicsRotation3D);
- QGraphicsRotation3D *copy = new QGraphicsRotation3D(parent);
- copy->setOrigin(d->origin);
- copy->setAxis(d->axis);
- copy->setAngle(d->angle);
- return copy;
-}
-
-/*!
- \fn void QGraphicsRotation3D::originChanged()
-
- Signal that is emitted when origin() changes.
-*/
-
-/*!
- \fn void QGraphicsRotation3D::angleChanged()
-
- Signal that is emitted when angle() changes.
-*/
-
-/*!
- \fn void QGraphicsRotation3D::axisChanged()
-
- Signal that is emitted when axis() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/graphicsview/qgraphicsrotation3d.h b/src/threed/graphicsview/qgraphicsrotation3d.h
deleted file mode 100644
index 4ba47e84..00000000
--- a/src/threed/graphicsview/qgraphicsrotation3d.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSROTATION3D_H
-#define QGRAPHICSROTATION3D_H
-
-#include "qgraphicstransform3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsRotation3DPrivate;
-
-class Q_QT3D_EXPORT QGraphicsRotation3D : public QGraphicsTransform3D
-{
- Q_OBJECT
- Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
- Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
-public:
- QGraphicsRotation3D(QObject *parent = 0);
- ~QGraphicsRotation3D();
-
- QVector3D origin() const;
- void setOrigin(const QVector3D &value);
-
- qreal angle() const;
- void setAngle(qreal value);
-
- QVector3D axis() const;
- void setAxis(const QVector3D &value);
-
- void applyTo(QMatrix4x4 *matrix) const;
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-Q_SIGNALS:
- void originChanged();
- void angleChanged();
- void axisChanged();
-
-private:
- QScopedPointer<QGraphicsRotation3DPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGraphicsRotation3D)
- Q_DECLARE_PRIVATE(QGraphicsRotation3D)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicsscale3d.cpp b/src/threed/graphicsview/qgraphicsscale3d.cpp
deleted file mode 100644
index cbf060bd..00000000
--- a/src/threed/graphicsview/qgraphicsscale3d.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicsscale3d.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsScale3D
- \brief The QGraphicsScale3D class supports scaling of items in 3D.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- \sa QGraphicsRotation3D, QGraphicsTranslation3D
-*/
-
-/*!
- \qmlclass Scale3D QGraphicsScale3D
- \brief The Scale3D item supports scaling of items in 3D.
- \since 4.8
- \ingroup qt3d::qml3d
-
- 3D items in QML can have a simple scale applied directly as follows:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- scale: 0.5
- }
- \endcode
-
- An alternative is to use Scale3D to apply a transform directly
- to an item as part of a sequence of transformations:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- transform: [
- Translation3D { translate: Qt.vector3d(5, 0, 0) },
- Scale3D { scale: 0.5 }
- ]
- }
- \endcode
-
- This allows the application writer to control exactly when the
- scale occurs relative to other transformations. In the example
- above, the item is first translated by 5 units along the x-axis,
- and then the co-ordinates are scaled by half. This is distinct
- from the following example which scales the object to half its
- original size and then translates it by 5 units along the x-axis:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- transform: [
- Scale3D { scale: 0.5 },
- Translation3D { translate: Qt.vector3d(5, 0, 0) }
- ]
- }
- \endcode
-
- The scale property on the item itself is applied before
- any of the transforms. So the previous example is equivalent to:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- scale: 0.5
- transform: [
- Translation3D { translate: Qt.vector3d(5, 0, 0) }
- ]
- }
- \endcode
-
- Scale values can also affect the x, y, and z axes by different amounts
- by using a \c{vector3D} value:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- transform: [
- Scale3D { scale: Qt.vector3d(0.5, 0.2, 1.0) },
- Translation3D { translate: Qt.vector3d(5, 0, 0) }
- ]
- }
- \endcode
-
- \sa Rotation3D, Translation3D
-*/
-
-class QGraphicsScale3DPrivate
-{
-public:
- QGraphicsScale3DPrivate()
- : scale(1, 1, 1)
- , isIdentityScale(true)
- , isIdentityOrigin(true)
- {}
-
- QVector3D origin;
- QVector3D scale;
- bool isIdentityScale;
- bool isIdentityOrigin;
-};
-
-/*!
- Construct a 3D scale transform and attach it to \a parent.
-*/
-QGraphicsScale3D::QGraphicsScale3D(QObject *parent)
- : QGraphicsTransform3D(parent), d_ptr(new QGraphicsScale3DPrivate)
-{
-}
-
-/*!
- Destroy this 3D scale transform.
-*/
-QGraphicsScale3D::~QGraphicsScale3D()
-{
-}
-
-/*!
- \property QGraphicsScale3D::origin
- \brief the origin about which to scale.
-
- The default value for this property is (0, 0, 0).
-*/
-
-/*!
- \qmlproperty vector3D Scale3D::origin
-
- The origin about which to scale. The default value for this
- property is (0, 0, 0).
-*/
-
-QVector3D QGraphicsScale3D::origin() const
-{
- Q_D(const QGraphicsScale3D);
- return d->origin;
-}
-
-void QGraphicsScale3D::setOrigin(const QVector3D &value)
-{
- Q_D(QGraphicsScale3D);
-
- // Optimise for the common case of setting the origin to 0, 0, 0
- // Also minimise the number of floating point compares required
- bool changed = false;
- QVector3D v = value;
-
- // Are we about to set to 0, 0, 0 ...?
- // Normalise inbound value & record in bool to save on compares
- bool isSetToZeroOrigin = false;
- if (qFuzzyIsNull(v.x()) && qFuzzyIsNull(v.y()) && qFuzzyIsNull(v.z()))
- {
- v = QVector3D(0, 0, 0);
- isSetToZeroOrigin = true;
- }
- if (!isSetToZeroOrigin)
- {
- if (d->origin != v)
- {
- d->origin = v;
- d->isIdentityOrigin = false;
- changed = true;
- }
- }
- else
- {
- if (!d->isIdentityOrigin)
- {
- d->origin = v;
- d->isIdentityOrigin = true;
- changed = true;
- }
- }
- if (changed)
- {
- emit transformChanged();
- emit originChanged();
- }
-}
-
-/*!
- \property QGraphicsScale3D::scale
- \brief the amount with which to scale each component.
-
- The default value for this property is QVector3D(1, 1, 1).
-*/
-
-/*!
- \qmlproperty vector3D Scale3D::scale
-
- The amount with which to scale each component. The default value for
- this property is (1, 1, 1).
-
- This property can be specified as either a vector3D or a single
- floating-point value. A single floating-point value will set
- the x, y, and z scale components to the same value. In other words,
- the following two transformations are equivalent:
-
- \code
- Scale3D { scale: 2 }
- Scale3D { scale: Qt.vector3d(2, 2, 2) }
- \endcode
-*/
-
-QVector3D QGraphicsScale3D::scale() const
-{
- Q_D(const QGraphicsScale3D);
- return d->scale;
-}
-
-void QGraphicsScale3D::setScale(const QVector3D &value)
-{
- Q_D(QGraphicsScale3D);
-
- // Optimise for the common case of setting the scale to 1, 1, 1
- // Also minimise the number of floating point compares required
- bool changed = false;
- QVector3D v = value;
-
- // Are we about to set to 1, 1, 1 ...?
- // Normalise inbound value & record in bool to save on compares
- bool isSetToIdentity = false;
- if (qFuzzyIsNull(v.x() - 1.0f) && qFuzzyIsNull(v.y() - 1.0f) && qFuzzyIsNull(v.z() - 1.0f))
- {
- v = QVector3D(1, 1, 1);
- isSetToIdentity = true;
- }
- if (!isSetToIdentity)
- {
- if (d->scale != v)
- {
- d->scale = v;
- d->isIdentityScale = false;
- changed = true;
- }
- }
- else
- {
- if (!d->isIdentityScale)
- {
- d->scale = v;
- d->isIdentityScale = true;
- changed = true;
- }
- }
- if (changed)
- {
- emit transformChanged();
- emit scaleChanged();
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScale3D::applyTo(QMatrix4x4 *matrix) const
-{
- Q_D(const QGraphicsScale3D);
- if (!d->isIdentityScale)
- {
- if (d->isIdentityOrigin)
- {
- matrix->scale(d->scale);
- }
- else
- {
- matrix->translate(d->origin);
- matrix->scale(d->scale);
- matrix->translate(-d->origin);
- }
- }
-}
-
-/*!
- \internal
-*/
-QGraphicsTransform3D *QGraphicsScale3D::clone(QObject *parent) const
-{
- Q_D(const QGraphicsScale3D);
- QGraphicsScale3D *copy = new QGraphicsScale3D(parent);
- copy->setOrigin(d->origin);
- copy->setScale(d->scale);
- return copy;
-}
-
-/*!
- \fn void QGraphicsScale3D::originChanged()
-
- Signal that is emitted when origin() changes.
-*/
-
-/*!
- \fn void QGraphicsScale3D::scaleChanged()
-
- Signal that is emitted when scale() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/graphicsview/qgraphicsscale3d.h b/src/threed/graphicsview/qgraphicsscale3d.h
deleted file mode 100644
index 36a6ede5..00000000
--- a/src/threed/graphicsview/qgraphicsscale3d.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSSCALE3D_H
-#define QGRAPHICSSCALE3D_H
-
-#include "qgraphicstransform3d.h"
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsScale3DPrivate;
-
-class Q_QT3D_EXPORT QGraphicsScale3D : public QGraphicsTransform3D
-{
- Q_OBJECT
- Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
- Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
-public:
- QGraphicsScale3D(QObject *parent = 0);
- ~QGraphicsScale3D();
-
- QVector3D origin() const;
- void setOrigin(const QVector3D &value);
-
- QVector3D scale() const;
- void setScale(const QVector3D &value);
-
- void applyTo(QMatrix4x4 *matrix) const;
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-Q_SIGNALS:
- void originChanged();
- void scaleChanged();
-
-private:
- QScopedPointer<QGraphicsScale3DPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGraphicsScale3D)
- Q_DECLARE_PRIVATE(QGraphicsScale3D)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicstransform3d.cpp b/src/threed/graphicsview/qgraphicstransform3d.cpp
deleted file mode 100644
index 1cc34383..00000000
--- a/src/threed/graphicsview/qgraphicstransform3d.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicstransform3d.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsTransform3D
- \brief The QGraphicsTransform3D class is an abstract base class for building 3D transformations.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- QGraphicsTransform3D lets you create and control advanced transformations
- that can be configured independently using specialized properties.
- Scene nodes have an associated list of transforms, which are applied
- in order, one at a time, to the modelview matrix. Transformations are
- computed in true 3D space using QMatrix4x4.
-
- QGraphicsTransform3D is particularly useful for animations. Whereas
- QGLPainter::modelViewMatrix() lets you assign any transform directly,
- there is no direct way to interpolate between two different
- transformations (e.g., when transitioning between two states, each for
- which the item has a different arbitrary transform assigned). Using
- QGraphicsTransform3D you can interpolate the property values of each
- independent transformation. The resulting operation is then combined into a
- single transform which is applied to the modelview matrix during drawing.
-
- If you want to create your own configurable transformation, you can create
- a subclass of QGraphicsTransform3D (or any or the existing subclasses), and
- reimplement the pure virtual applyTo() function, which takes a pointer to a
- QMatrix4x4. Each operation you would like to apply should be exposed as
- properties (e.g., customTransform->setVerticalShear(2.5)). Inside you
- reimplementation of applyTo(), you can modify the provided transform
- respectively.
-
- \sa QGraphicsScale3D, QGraphicsRotation3D, QGraphicsTranslation3D
- \sa QGraphicsBillboardTransform
-*/
-
-/*!
- \fn QGraphicsTransform3D::QGraphicsTransform3D(QObject *parent)
-
- Constructs a 3D transformation and attaches it to \a parent.
-*/
-
-/*!
- \fn QGraphicsTransform3D::~QGraphicsTransform3D()
-
- Destroys this 3D transformation.
-*/
-
-/*!
- \fn void QGraphicsTransform3D::applyTo(QMatrix4x4 *matrix) const
-
- Applies the effect of this transformation to the specified
- modelview \a matrix.
-*/
-
-/*!
- \fn QGraphicsTransform3D *QGraphicsTransform3D::clone(QObject *parent) const
-
- Clones a copy of this transformation and attaches the clone to \a parent.
-*/
-
-/*!
- \fn void QGraphicsTransform3D::transformChanged()
-
- Signal that is emitted whenever any of the transformation's
- parameters are changed.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/graphicsview/qgraphicstransform3d.h b/src/threed/graphicsview/qgraphicstransform3d.h
deleted file mode 100644
index 024a9786..00000000
--- a/src/threed/graphicsview/qgraphicstransform3d.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSTRANSFORM3D_H
-#define QGRAPHICSTRANSFORM3D_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qmatrix4x4.h>
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class Q_QT3D_EXPORT QGraphicsTransform3D : public QObject
-{
- Q_OBJECT
-public:
- QGraphicsTransform3D(QObject *parent = 0) : QObject(parent) {}
- ~QGraphicsTransform3D() {}
-
- virtual void applyTo(QMatrix4x4 *matrix) const = 0;
- virtual QGraphicsTransform3D *clone(QObject *parent = 0) const = 0;
-
-Q_SIGNALS:
- void transformChanged();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/graphicsview/qgraphicstranslation3d.cpp b/src/threed/graphicsview/qgraphicstranslation3d.cpp
deleted file mode 100644
index 1b5d1211..00000000
--- a/src/threed/graphicsview/qgraphicstranslation3d.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgraphicstranslation3d.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsTranslation3D
- \brief The QGraphicsTranslation3D class supports translation of 3D items.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::graphicsview
-
- QGraphicsTranslation3D is derived directly from QGraphicsTransform, and
- provides a \l translate property to specify the 3D vector to
- apply to incoming co-ordinates.
-
- The \l progress property can be used to perform animation along a
- translation vector by varying the progress value between 0 and 1.
- Overshoot animations are also possible by setting the progress
- value to something outside this range. The default progress
- value is 1.
-
- \sa QGraphicsRotation3D, QGraphicsScale3D
-*/
-
-/*!
- \qmlclass Translation3D QGraphicsTranslation3D
- \brief The Translation3D item supports translation of items in 3D.
- \since 4.8
- \ingroup qt3d::qml3d
-
- 3D items in QML are typically positioned directly as follows:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- position: Qt.vector3d(0, 5, 10)
- }
- \endcode
-
- However, it can sometimes be useful to translate an object along a
- vector under the control of an animation. The Translate3D
- element can be used for this purpose. The following example
- translates the object along a straight-line path 5 units to
- the right of its original position, and then back again:
-
- \code
- Item3D {
- mesh: Mesh { source: "chair.3ds" }
- position: Qt.vector3d(0, 5, 10)
- transform: [
- Translation3D {
- translate: Qt.vector3d(5, 0, 0)
- SequentialAnimation on progress {
- running: true
- loops: Animation.Infinite
- NumberAnimation { to : 1.0; duration: 300 }
- NumberAnimation { to : 0.0; duration: 300 }
- }
- }
- ]
- }
- \endcode
-
- \sa Rotation3D, Scale3D
-*/
-
-class QGraphicsTranslation3DPrivate
-{
-public:
- QGraphicsTranslation3DPrivate() : progress(1.0f) {}
-
- QVector3D translate;
- qreal progress;
-};
-
-/*!
- Constructs a new translation and attaches it to \a parent.
-*/
-QGraphicsTranslation3D::QGraphicsTranslation3D(QObject *parent)
- : QGraphicsTransform3D(parent), d_ptr(new QGraphicsTranslation3DPrivate)
-{
-}
-
-/*!
- Destroys this translation.
-*/
-QGraphicsTranslation3D::~QGraphicsTranslation3D()
-{
-}
-
-/*!
- \property QGraphicsTranslation3D::translate
- \brief the translation to apply to incoming co-ordinates.
-
- The default value for this property is (0, 0, 0).
-*/
-
-/*!
- \qmlproperty vector3D Translation3D::translate
-
- The translation to apply to incoming co-ordinates. The default value
- for this property is (0, 0, 0).
-*/
-
-QVector3D QGraphicsTranslation3D::translate() const
-{
- Q_D(const QGraphicsTranslation3D);
- return d->translate;
-}
-
-void QGraphicsTranslation3D::setTranslate(const QVector3D &value)
-{
- Q_D(QGraphicsTranslation3D);
- if (d->translate != value) {
- d->translate = value;
- emit transformChanged();
- emit translateChanged();
- }
-}
-
-/*!
- \property QGraphicsTranslation3D::progress
- \brief the progress along the translation vector, from 0 to 1.
-
- The default value for this property is 1.
-
- This property can be used to perform animation along a translation
- vector by varying the progress between 0 and 1. Overshoot animations
- are also possible by setting the value to something outside this range.
-*/
-
-/*!
- \qmlproperty real Translation3D::progress
-
- The progress along the translation vector, from 0 to 1. The default
- value for this property is 1.
-
- This property can be used to perform animation along a translation
- vector by varying the progress between 0 and 1. Overshoot animations
- are also possible by setting the value to something outside this range.
-*/
-
-qreal QGraphicsTranslation3D::progress() const
-{
- Q_D(const QGraphicsTranslation3D);
- return d->progress;
-}
-
-void QGraphicsTranslation3D::setProgress(qreal value)
-{
- Q_D(QGraphicsTranslation3D);
- if (d->progress != value) {
- d->progress = value;
- emit transformChanged();
- emit progressChanged();
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsTranslation3D::applyTo(QMatrix4x4 *matrix) const
-{
- Q_D(const QGraphicsTranslation3D);
- matrix->translate(d->translate * d->progress);
-}
-
-/*!
- \internal
-*/
-QGraphicsTransform3D *QGraphicsTranslation3D::clone(QObject *parent) const
-{
- Q_D(const QGraphicsTranslation3D);
- QGraphicsTranslation3D *copy = new QGraphicsTranslation3D(parent);
- copy->setTranslate(d->translate);
- copy->setProgress(d->progress);
- return copy;
-}
-
-/*!
- \fn void QGraphicsTranslation3D::translateChanged()
-
- Signal that is emitted when translate() changes.
-*/
-
-/*!
- \fn void QGraphicsTranslation3D::progressChanged()
-
- Signal that is emitted when progress() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/graphicsview/qgraphicstranslation3d.h b/src/threed/graphicsview/qgraphicstranslation3d.h
deleted file mode 100644
index 0ccab5d3..00000000
--- a/src/threed/graphicsview/qgraphicstranslation3d.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGRAPHICSTRANSLATION3D_H
-#define QGRAPHICSTRANSLATION3D_H
-
-#include "qgraphicstransform3d.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsTranslation3DPrivate;
-
-class Q_QT3D_EXPORT QGraphicsTranslation3D : public QGraphicsTransform3D
-{
- Q_OBJECT
- Q_PROPERTY(QVector3D translate READ translate WRITE setTranslate NOTIFY translateChanged)
- Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
-public:
- QGraphicsTranslation3D(QObject *parent = 0);
- ~QGraphicsTranslation3D();
-
- QVector3D translate() const;
- void setTranslate(const QVector3D &value);
-
- qreal progress() const;
- void setProgress(qreal value);
-
- void applyTo(QMatrix4x4 *matrix) const;
- QGraphicsTransform3D *clone(QObject *parent) const;
-
-Q_SIGNALS:
- void translateChanged();
- void progressChanged();
-
-private:
- QScopedPointer<QGraphicsTranslation3DPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGraphicsTranslation3D)
- Q_DECLARE_PRIVATE(QGraphicsTranslation3D)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/materials/materials.pri b/src/threed/materials/materials.pri
deleted file mode 100644
index 27ba1ffe..00000000
--- a/src/threed/materials/materials.pri
+++ /dev/null
@@ -1,18 +0,0 @@
-
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- materials/qglabstractmaterial.h \
- materials/qglcolormaterial.h \
- materials/qglmaterial.h \
- materials/qgltwosidedmaterial.h
-
-SOURCES += \
- qglabstractmaterial.cpp \
- qglcolormaterial.cpp \
- qglmaterial.cpp \
- qgltwosidedmaterial.cpp
-
-PRIVATE_HEADERS += \
- qglmaterial_p.h
diff --git a/src/threed/materials/qglabstractmaterial.cpp b/src/threed/materials/qglabstractmaterial.cpp
deleted file mode 100644
index 63406cdf..00000000
--- a/src/threed/materials/qglabstractmaterial.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglabstractmaterial.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAbstractMaterial
- \since 4.8
- \brief The QGLAbstractMaterial class provides a standard interface for rendering surface materials with GL.
- \ingroup qt3d
- \ingroup qt3d::materials
-
- Materials are the primary method to specify the surface appearance of an
- object, as distinct from the geometry for the object. Materials have an
- almost endless variety of parameters:
-
- \list
- \o Properties of the material under various lighting conditions;
- i.e., the traditional parameters for ambient, diffuse, specular, etc.
- \o Textures in multiple layers, with different combination modes;
- decal, modulate, replace, etc.
- \o Environmental conditions such as fogging.
- \o Alpha values for opacity and blending.
- \o Interpolation factors for animated surface effects.
- \o etc
- \endlist
-
- QGLAbstractMaterial is the base class for all such materials.
- It provides a very simple API to bind() a material to a QGLPainter
- when the material needs to be rendered, to release() a material
- from a QGLPainter when the material is no longer needed, and to
- prepareToDraw().
-
- Subclasses of QGLAbstractMaterial implement specific materials.
- QGLMaterial provides the traditional ambient, diffuse, specular, etc
- parameters for lighting properties.
-
- Materials are distinct from \i effects, which have the base class
- QGLAbstractEffect. Effects are typically shader programs that are
- used to render a specific type of material. The material's bind()
- function will use QGLPainter::setStandardEffect() or
- QGLPainter::setUserEffect() to select the exact effect that is
- needed to render the material.
-
- It is possible that the same material may be rendered with different
- effects depending upon the material parameters. For example, a lit
- material may select a simpler and more efficient shader program effect
- if the material has the default spotlight properties, or if the
- QGLPainter only has a single light source specified.
-
- \sa QGLMaterial, QGLAbstractEffect
-*/
-
-/*!
- Constructs a new material and attaches it to \a parent.
-*/
-QGLAbstractMaterial::QGLAbstractMaterial(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys this material.
-*/
-QGLAbstractMaterial::~QGLAbstractMaterial()
-{
-}
-
-/*!
- Returns the material lighting parameters for rendering the front
- faces of fragments with this abstract material. The default
- implementation returns null.
-
- This function is provided as a convenience for applications that
- wish to alter the lighting parameters or textures of a material,
- without regard to any wrapping that has been performed to add
- blending or other options.
-
- \sa back(), QGLMaterial
-*/
-QGLMaterial *QGLAbstractMaterial::front() const
-{
- return 0;
-}
-
-/*!
- Returns the material lighting parameters for rendering the back
- faces of fragments with this abstract material. The default
- implementation returns null, which indicates that front()
- is also used to render back faces.
-
- \sa front(), QGLMaterial
-*/
-QGLMaterial *QGLAbstractMaterial::back() const
-{
- return 0;
-}
-
-/*!
- \fn bool QGLAbstractMaterial::isTransparent() const
-
- Returns true if this material is transparent and will therefore
- require the \c{GL_BLEND} mode to be enabled to render the material.
- Returns false if the material is fully opaque.
-*/
-
-/*!
- \fn void QGLAbstractMaterial::bind(QGLPainter *painter)
-
- Binds resources to \a painter that are needed to render this
- material; textures, shader programs, blending modes, etc.
-
- In the following example, lit material parameters and a texture
- are bound to the \a painter, for rendering with the standard
- QGL::LitModulateTexture2D effect:
-
- \code
- void TexturedLitMaterial::bind(QGLPainter *painter)
- {
- painter->setStandardEffect(QGL::LitModulateTexture2D);
- painter->setFaceMaterial(QGL::AllFaces, material);
- painter->glActiveTexture(GL_TEXTURE0);
- texture->bind();
- }
- \endcode
-
- Normally the effect is bound to \a painter during the bind()
- function. However, some materials may need to use different
- effects depending upon which attributes are present in the
- geometry. For example, a per-vertex color effect instead of a
- uniform color effect if the geometry has the QGL::Color attribute.
- The prepareToDraw() function can be overridden to alter the
- effect once the specific set of geometry attributes are known.
-
- \sa release(), prepareToDraw()
-*/
-
-/*!
- \fn void QGLAbstractMaterial::release(QGLPainter *painter, QGLAbstractMaterial *next)
-
- Releases resources from \a painter that were used to render this
- material. The QGLPainter::effect() can be left bound to \a painter,
- but other resources such as textures and blending modes
- should be disabled.
-
- If \a next is not null, then it indicates the next material that
- will be bound to \a painter. If \a next is the same type of
- material as this material, then this function can choose not to
- release resources that would be immediately re-bound to
- \a painter in the next call to bind().
-
- In the following example, texture unit 0 is unbound if \a painter
- is about to switch to another effect that is not an instance
- of \c{TexturedLitMaterial}:
-
- \code
- void TexturedLitMaterial::release(QGLPainter *painter, QGLAbstractMaterial *next)
- {
- if (!qobject_cast<TexturedLitMaterial *>(next)) {
- painter->glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- }
- \endcode
-
- \sa bind(), prepareToDraw()
-*/
-
-/*!
- Prepares to draw geometry to \a painter that has the specified
- set of vertex \a attributes. The default implementation
- does nothing.
-
- Multiple effects may be used to render some materials depending upon
- the available vertex attributes. For example, if QGL::Color is
- present in \a attributes, then a per-vertex color should be used
- instead of a single uniform color.
-
- This function is provided for such materials to have one last
- chance during QGLPainter::draw() to alter the QGLPainter::effect()
- to something that is tuned for the specific geometry. It can
- be assumed that bind() has already been called on this material.
-
- \sa bind(), release()
-*/
-void QGLAbstractMaterial::prepareToDraw(QGLPainter *painter, const QGLAttributeSet &attributes)
-{
- Q_UNUSED(painter);
- Q_UNUSED(attributes);
-}
-
-/*!
- \fn void QGLAbstractMaterial::materialChanged()
-
- Signal that is emitted when an object that is using this material
- should be redrawn because some property on the material has changed.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/materials/qglabstractmaterial.h b/src/threed/materials/qglabstractmaterial.h
deleted file mode 100644
index 8d4bd2e4..00000000
--- a/src/threed/materials/qglabstractmaterial.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLABSTRACTMATERIAL_H
-#define QGLABSTRACTMATERIAL_H
-
-#include <QtCore/qobject.h>
-#include "qglattributeset.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLPainter;
-class QGLMaterial;
-
-class Q_QT3D_EXPORT QGLAbstractMaterial : public QObject
-{
- Q_OBJECT
- Q_DISABLE_COPY(QGLAbstractMaterial)
-public:
- explicit QGLAbstractMaterial(QObject *parent = 0);
- ~QGLAbstractMaterial();
-
- virtual QGLMaterial *front() const;
- virtual QGLMaterial *back() const;
-
- virtual bool isTransparent() const = 0;
-
- virtual void bind(QGLPainter *painter) = 0;
- virtual void release(QGLPainter *painter, QGLAbstractMaterial *next) = 0;
- virtual void prepareToDraw(QGLPainter *painter, const QGLAttributeSet &attributes);
-
-Q_SIGNALS:
- void materialChanged();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/materials/qglcolormaterial.cpp b/src/threed/materials/qglcolormaterial.cpp
deleted file mode 100644
index 383deb13..00000000
--- a/src/threed/materials/qglcolormaterial.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcolormaterial.h"
-#include "qglpainter.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLColorMaterial
- \since 4.8
- \brief The QGLColorMaterial class implements flat or per-vertex color materials for 3D rendering.
- \ingroup qt3d
- \ingroup qt3d::materials
-
- When bound to a QGLPainter, QGLColorMaterial will select a flat
- color drawing effect, to render fragments with color(), ignoring
- any lights or textures that may be active on the QGLPainter state.
- If the geometry has the QGL::Color attribute, then a per-vertex
- color will be used instead and color() is ignored.
-
- \sa QGLMaterial
-*/
-
-class QGLColorMaterialPrivate
-{
-public:
- QGLColorMaterialPrivate() : color(255, 255, 255, 255) {}
-
- QColor color;
-};
-
-/*!
- Constructs a new flat color material and attaches it to \a parent.
-*/
-QGLColorMaterial::QGLColorMaterial(QObject *parent)
- : QGLAbstractMaterial(parent)
- , d_ptr(new QGLColorMaterialPrivate)
-{
-}
-
-/*!
- Destroys this flat color material.
-*/
-QGLColorMaterial::~QGLColorMaterial()
-{
-}
-
-/*!
- \property QGLColorMaterial::color
- \brief the flat color to use to render the material. The default
- color is white.
-
- If the geometry has per-vertex colors, then this property is ignored.
-
- \sa colorChanged()
-*/
-
-QColor QGLColorMaterial::color() const
-{
- Q_D(const QGLColorMaterial);
- return d->color;
-}
-
-void QGLColorMaterial::setColor(const QColor &color)
-{
- Q_D(QGLColorMaterial);
- if (d->color != color) {
- d->color = color;
- emit colorChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \reimp
-*/
-bool QGLColorMaterial::isTransparent() const
-{
- Q_D(const QGLColorMaterial);
- return d->color.alpha() != 255;
-}
-
-/*!
- \reimp
-*/
-void QGLColorMaterial::bind(QGLPainter *painter)
-{
- Q_D(const QGLColorMaterial);
- painter->setColor(d->color);
- // Effect is set during prepareToDraw().
-}
-
-/*!
- \reimp
-*/
-void QGLColorMaterial::release(QGLPainter *painter, QGLAbstractMaterial *next)
-{
- // No textures or other modes, so nothing to do here.
- Q_UNUSED(painter);
- Q_UNUSED(next);
-}
-
-/*!
- \reimp
-*/
-void QGLColorMaterial::prepareToDraw
- (QGLPainter *painter, const QGLAttributeSet &attributes)
-{
- if (attributes.contains(QGL::Color))
- painter->setStandardEffect(QGL::FlatPerVertexColor);
- else
- painter->setStandardEffect(QGL::FlatColor);
-}
-
-/*!
- \fn void QGLColorMaterial::colorChanged()
-
- Signal that is emitted when color() changes.
-
- \sa color()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/materials/qglcolormaterial.h b/src/threed/materials/qglcolormaterial.h
deleted file mode 100644
index 96600875..00000000
--- a/src/threed/materials/qglcolormaterial.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCOLORMATERIAL_H
-#define QGLCOLORMATERIAL_H
-
-#include "qglabstractmaterial.h"
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLColorMaterialPrivate;
-
-class Q_QT3D_EXPORT QGLColorMaterial : public QGLAbstractMaterial
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLColorMaterial)
- Q_DISABLE_COPY(QGLColorMaterial)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
-public:
- explicit QGLColorMaterial(QObject *parent = 0);
- ~QGLColorMaterial();
-
- QColor color() const;
- void setColor(const QColor &color);
-
- bool isTransparent() const;
- void bind(QGLPainter *painter);
- void release(QGLPainter *painter, QGLAbstractMaterial *next);
- void prepareToDraw(QGLPainter *painter, const QGLAttributeSet &attributes);
-
-Q_SIGNALS:
- void colorChanged();
-
-private:
- QScopedPointer<QGLColorMaterialPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/materials/qglmaterial.cpp b/src/threed/materials/qglmaterial.cpp
deleted file mode 100644
index 6b672180..00000000
--- a/src/threed/materials/qglmaterial.cpp
+++ /dev/null
@@ -1,587 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglmaterial.h"
-#include "qglmaterial_p.h"
-#include "qglpainter.h"
-#include "qgltexture2d.h"
-#include "qglmaterialcollection.h"
-#include "qgllightmodel.h"
-#include "qfileinfo.h"
-
-#include <QtCore/qurl.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLMaterial
- \brief The QGLMaterial class describes one-sided material properties for rendering fragments.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::materials
-
- \sa QGLTwoSidedMaterial
-*/
-
-/*!
- \qmlclass Material QGLMaterial
- \brief The Material item describes material properties for OpenGL drawing.
- \since 4.8
- \ingroup qt3d::qml3d
-*/
-
-QGLMaterialPrivate::QGLMaterialPrivate()
- : specularColor(0, 0, 0, 255),
- emittedLight(0, 0, 0, 255),
- shininess(0),
- collection(0),
- index(-1),
- used(false)
-{
- ambientColor.setRgbF(0.2f, 0.2f, 0.2f, 1.0f);
- diffuseColor.setRgbF(0.8f, 0.8f, 0.8f, 1.0f);
-}
-
-/*!
- Constructs a QGLMaterial object with its default values,
- and attaches it to \a parent.
-*/
-QGLMaterial::QGLMaterial(QObject *parent)
- : QGLAbstractMaterial(parent)
- , d_ptr(new QGLMaterialPrivate)
-{
-}
-
-/*!
- Destroys this QGLMaterial object.
-*/
-QGLMaterial::~QGLMaterial()
-{
-}
-
-/*!
- \property QGLMaterial::ambientColor
- \brief the ambient color of the material. The default value
- is (0.2, 0.2, 0.2, 1.0).
-
- \sa diffuseColor(), specularColor(), ambientColorChanged()
-*/
-
-/*!
- \qmlproperty color Material::ambientColor
- The ambient color of the material. The default value
- is (0.2, 0.2, 0.2, 1.0).
-
- \sa diffuseColor, specularColor
-*/
-
-QColor QGLMaterial::ambientColor() const
-{
- Q_D(const QGLMaterial);
- return d->ambientColor;
-}
-
-void QGLMaterial::setAmbientColor(const QColor& value)
-{
- Q_D(QGLMaterial);
- if (d->ambientColor != value) {
- d->ambientColor = value;
- emit ambientColorChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLMaterial::diffuseColor
- \brief the diffuse color of the material. The default value
- is (0.8, 0.8, 0.8, 1.0).
-
- \sa ambientColor(), specularColor(), diffuseColorChanged()
-*/
-
-/*!
- \qmlproperty color Material::diffuseColor
- The diffuse color of the material. The default value
- is (0.8, 0.8, 0.8, 1.0).
-
- \sa ambientColor, specularColor
-*/
-
-QColor QGLMaterial::diffuseColor() const
-{
- Q_D(const QGLMaterial);
- return d->diffuseColor;
-}
-
-void QGLMaterial::setDiffuseColor(const QColor& value)
-{
- Q_D(QGLMaterial);
- if (d->diffuseColor != value) {
- d->diffuseColor = value;
- emit diffuseColorChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLMaterial::specularColor
- \brief the specular color of the material. The default value
- is (0, 0, 0, 1).
-
- \sa ambientColor(), diffuseColor(), specularColorChanged()
-*/
-
-/*!
- \qmlproperty color Material::specularColor
- The specular color of the material. The default value
- is (0, 0, 0, 1).
-
- \sa ambientColor, diffuseColor
-*/
-
-QColor QGLMaterial::specularColor() const
-{
- Q_D(const QGLMaterial);
- return d->specularColor;
-}
-
-void QGLMaterial::setSpecularColor(const QColor& value)
-{
- Q_D(QGLMaterial);
- if (d->specularColor != value) {
- d->specularColor = value;
- emit specularColorChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLMaterial::emittedLight
- \brief the emitted light intensity of the material.
- The default value is (0.0, 0.0, 0.0, 1.0), which indicates
- that the material does not emit any light.
-
- \sa emittedLightChanged()
-*/
-
-/*!
- \qmlproperty color Material::emittedLight
- The emitted light intensity of the material.
- The default value is (0.0, 0.0, 0.0, 1.0), which indicates
- that the material does not emit any light.
-*/
-
-QColor QGLMaterial::emittedLight() const
-{
- Q_D(const QGLMaterial);
- return d->emittedLight;
-}
-
-void QGLMaterial::setEmittedLight(const QColor& value)
-{
- Q_D(QGLMaterial);
- if (d->emittedLight != value) {
- d->emittedLight = value;
- emit emittedLightChanged();
- emit materialChanged();
- }
-}
-
-/*!
- Sets ambientColor() to 20% of \a value, and diffuseColor() to 80% of
- \a value. This is a convenience function for quickly setting ambient
- and diffuse lighting colors based on a flat color.
-
- \sa ambientColor(), diffuseColor()
-*/
-void QGLMaterial::setColor(const QColor& value)
-{
- Q_D(QGLMaterial);
- d->ambientColor.setRgbF
- (value.redF() * 0.2f, value.greenF() * 0.2f,
- value.blueF() * 0.2f, value.alphaF());
- d->diffuseColor.setRgbF
- (value.redF() * 0.8f, value.greenF() * 0.8f,
- value.blueF() * 0.8f, value.alphaF());
- emit ambientColorChanged();
- emit diffuseColorChanged();
- emit materialChanged();
-}
-
-/*!
- \property QGLMaterial::shininess
- \brief the specular exponent of the material, or how shiny it is.
- Must be between 0 and 128. The default value is 0. A value outside
- this range will be clamped to the range when the property is set.
-
- \sa shininessChanged()
-*/
-
-/*!
- \qmlproperty real Material::shininess
- The specular exponent of the material, or how shiny it is.
- Must be between 0 and 128. The default value is 0. A value outside
- this range will be clamped to the range when the property is set.
-*/
-
-qreal QGLMaterial::shininess() const
-{
- Q_D(const QGLMaterial);
- return d->shininess;
-}
-
-void QGLMaterial::setShininess(qreal value)
-{
- Q_D(QGLMaterial);
- if (value < 0)
- value = 0;
- else if (value > 128)
- value = 128;
- if (d->shininess != value) {
- d->shininess = value;
- emit shininessChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLMaterial::texture
- \brief the 2D texture associated with \a layer on this material;
- null if no texture.
-
- Layer 0 is normally the primary texture associated with the material.
- Multiple texture layers may be specified for materials with special
- blending effects or to specify ambient, diffuse, or specular colors
- pixel-by-pixel.
-
- \sa texturesChanged()
-*/
-QGLTexture2D *QGLMaterial::texture(int layer) const
-{
- Q_D(const QGLMaterial);
- return d->textures.value(layer, 0);
-}
-
-void QGLMaterial::setTexture(QGLTexture2D *value, int layer)
-{
- Q_ASSERT(layer >= 0);
- Q_D(QGLMaterial);
- QGLTexture2D *prev = d->textures.value(layer, 0);
- if (prev != value) {
- delete prev;
- d->textures[layer] = value;
- emit texturesChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLMaterial::textureUrl
- \brief URL of the 2D texture associated with \a layer on this material.
-
- By default \a layer is 0, the primary texture.
-
- If the URL has not been specified, then this property is a null QUrl.
-
- Setting this property to a non-empty URL will replace any existing texture
- with a new texture based on the image at the given \a url. If that
- image is not a valid texture then the new texture will be a null texture.
-
- If an empty url is set, this has the same effect as \c{setTexture(0)}.
-
- \sa texture(), setTexture()
-*/
-QUrl QGLMaterial::textureUrl(int layer) const
-{
- Q_D(const QGLMaterial);
- QGLTexture2D *tex = d->textures.value(layer, 0);
- if (tex)
- return tex->url();
- else
- return QUrl();
-}
-
-void QGLMaterial::setTextureUrl(const QUrl &url, int layer)
-{
- Q_ASSERT(layer >= 0);
- if (textureUrl(layer) != url)
- {
- QGLTexture2D *tex = 0;
- if (!url.isEmpty())
- {
- tex = new QGLTexture2D(this);
- connect(tex, SIGNAL(textureUpdated()), this, SIGNAL(texturesChanged()));
- tex->setUrl(url);
- }
- setTexture(tex, layer);
- }
-}
-
-/*!
- \enum QGLMaterial::TextureCombineMode
- This enum defines the mode to use when combining a texture with
- the material colors on a QGLMaterial object.
-
- \value Modulate Modulate the texture with the lighting
- conditions to produce a lit texture.
- \value Decal Combine the texture with the lighting conditions
- to produce a decal effect.
- \value Replace Replace with the contents of the texture,
- ignoring colors and lighting conditions.
-*/
-
-/*!
- \property QGLMaterial::textureCombineMode
- \brief the texture combine mode associated with \a layer on this material.
- The default value is \l Modulate.
-
- \sa texturesChanged()
-*/
-
-QGLMaterial::TextureCombineMode QGLMaterial::textureCombineMode(int layer) const
-{
- Q_D(const QGLMaterial);
- return d->textureModes.value(layer, Modulate);
-}
-
-void QGLMaterial::setTextureCombineMode(QGLMaterial::TextureCombineMode mode, int layer)
-{
- Q_D(QGLMaterial);
- if (d->textureModes.value(layer, Modulate) != mode) {
- d->textureModes[layer] = mode;
- emit texturesChanged();
- emit materialChanged();
- }
-}
-
-/*!
- Returns the number of texture layers associated with this material.
-
- The return value may be larger than the number of actual texture
- layers if some of the intermediate layers are null. For example,
- setting layers 0 and 2 will report textureLayerCount() as 3.
- The main use of this value is to iterate over all layers.
-
- \sa texture()
-*/
-int QGLMaterial::textureLayerCount() const
-{
- Q_D(const QGLMaterial);
- int maxLayer = -1;
- if (!d->textures.isEmpty())
- maxLayer = qMax(maxLayer, (d->textures.end() - 1).key());
- return maxLayer + 1;
-}
-
-/*!
- \reimp
- Returns this material.
-*/
-QGLMaterial *QGLMaterial::front() const
-{
- return const_cast<QGLMaterial *>(this);
-}
-
-/*!
- \reimp
-*/
-bool QGLMaterial::isTransparent() const
-{
- Q_D(const QGLMaterial);
- bool transparent = (d->diffuseColor.alpha() != 255);
- QMap<int, QGLTexture2D *>::ConstIterator it;
- for (it = d->textures.begin(); it != d->textures.end(); ++it) {
- TextureCombineMode mode = d->textureModes.value(it.key(), Modulate);
- if (mode == Modulate) {
- // Texture alpha adds to the current alpha.
- if (it.value() && it.value()->hasAlphaChannel())
- transparent = true;
- } else if (mode == Replace) {
- // Replace the current alpha with the texture's alpha.
- if (it.value())
- transparent = it.value()->hasAlphaChannel();
- }
- }
- return transparent;
-}
-
-/*!
- \reimp
-*/
-void QGLMaterial::bind(QGLPainter *painter)
-{
- painter->setFaceMaterial(QGL::AllFaces, this);
- const_cast<QGLLightModel *>(painter->lightModel())
- ->setModel(QGLLightModel::OneSided); // FIXME
- bindTextures(painter);
-}
-
-/*!
- \internal
-*/
-void QGLMaterial::bindTextures(QGLPainter *painter)
-{
- Q_D(const QGLMaterial);
- QMap<int, QGLTexture2D *>::ConstIterator it;
- for (it = d->textures.begin(); it != d->textures.end(); ++it) {
- QGLTexture2D *tex = it.value();
- painter->glActiveTexture(GL_TEXTURE0 + it.key());
- if (tex)
- tex->bind();
- else
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-}
-
-/*!
- \reimp
-*/
-void QGLMaterial::release(QGLPainter *painter, QGLAbstractMaterial *next)
-{
- Q_UNUSED(next);
- Q_D(const QGLMaterial);
- QMap<int, QGLTexture2D *>::ConstIterator it;
- for (it = d->textures.begin(); it != d->textures.end(); ++it) {
- painter->glActiveTexture(GL_TEXTURE0 + it.key());
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-}
-
-/*!
- \reimp
-*/
-void QGLMaterial::prepareToDraw
- (QGLPainter *painter, const QGLAttributeSet &attributes)
-{
- bindEffect(painter, attributes, false);
-}
-
-/*!
- \internal
-*/
-void QGLMaterial::bindEffect
- (QGLPainter *painter, const QGLAttributeSet &attributes, bool twoSided)
-{
- Q_D(const QGLMaterial);
- Q_UNUSED(twoSided);
- QGL::StandardEffect effect = QGL::LitMaterial;
- if (!d->textures.isEmpty() && attributes.contains(QGL::TextureCoord0)) {
- // TODO: different combine modes for each layer.
- QGLMaterial::TextureCombineMode mode =
- d->textureModes.value(0, Modulate);
- if (mode == Replace)
- effect = QGL::FlatReplaceTexture2D;
- else if (mode == Decal)
- effect = QGL::LitDecalTexture2D;
- else
- effect = QGL::LitModulateTexture2D;
- }
- painter->setStandardEffect(effect);
-}
-
-/*!
- \fn void QGLMaterial::ambientColorChanged()
-
- This signal is emitted when ambientColor() changes.
-
- \sa ambientColor(), setAmbientColor(), materialChanged()
-*/
-
-/*!
- \fn void QGLMaterial::diffuseColorChanged()
-
- This signal is emitted when diffuseColor() changes.
-
- \sa diffuseColor(), setDiffuseColor(), materialChanged()
-*/
-
-/*!
- \fn void QGLMaterial::specularColorChanged()
-
- This signal is emitted when specularColor() changes.
-
- \sa specularColor(), setSpecularColor(), materialChanged()
-*/
-
-/*!
- \fn void QGLMaterial::emittedLightChanged()
-
- This signal is emitted when emittedLight() changes.
-
- \sa emittedLight(), setEmittedLight(), materialChanged()
-*/
-
-/*!
- \fn void QGLMaterial::shininessChanged()
-
- This signal is emitted when shininess() changes.
-
- \sa shininess(), setShininess(), materialChanged()
-*/
-
-/*!
- \fn void QGLMaterial::texturesChanged()
-
- This signal is emitted when the texture layers associated with
- this material change.
-
- \sa texture(), setTexture(), materialChanged()
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QGLMaterial &material)
-{
- dbg << &material <<
- "-- Amb:" << material.ambientColor() <<
- "-- Diff:" << material.diffuseColor() <<
- "-- Spec:" << material.specularColor() <<
- "-- Shin:" << material.shininess();
- for (int i = 0; i < material.textureLayerCount(); ++i)
- if (material.texture(i) != 0)
- dbg << "\n -- Tex" << i << ":" << material.texture(i)
- << material.texture(i)->objectName();
- dbg << "\n";
- return dbg;
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/materials/qglmaterial.h b/src/threed/materials/qglmaterial.h
deleted file mode 100644
index 148e3510..00000000
--- a/src/threed/materials/qglmaterial.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLMATERIAL_H
-#define QGLMATERIAL_H
-
-#include "qglabstractmaterial.h"
-#include <QtCore/qobject.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtGui/qcolor.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLMaterialPrivate;
-class QGLTexture2D;
-class QGLTextureCube;
-class QGLPainter;
-class QGLMaterialCollection;
-class QGLTwoSidedMaterial;
-
-class Q_QT3D_EXPORT QGLMaterial : public QGLAbstractMaterial
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLMaterial)
- Q_DISABLE_COPY(QGLMaterial)
- Q_ENUMS(TextureCombineMode)
- Q_PROPERTY(QColor ambientColor READ ambientColor WRITE setAmbientColor NOTIFY ambientColorChanged)
- Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
- Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged)
- Q_PROPERTY(QColor emittedLight READ emittedLight WRITE setEmittedLight NOTIFY emittedLightChanged)
- Q_PROPERTY(qreal shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
- Q_PROPERTY(QGLTexture2D *texture READ texture WRITE setTexture NOTIFY texturesChanged)
- Q_PROPERTY(QGLMaterial::TextureCombineMode textureCombineMode READ textureCombineMode WRITE setTextureCombineMode NOTIFY texturesChanged)
- Q_PROPERTY(QUrl textureUrl READ textureUrl WRITE setTextureUrl NOTIFY texturesChanged)
-public:
- explicit QGLMaterial(QObject *parent = 0);
- ~QGLMaterial();
-
- QColor ambientColor() const;
- void setAmbientColor(const QColor& value);
-
- QColor diffuseColor() const;
- void setDiffuseColor(const QColor& value);
-
- QColor specularColor() const;
- void setSpecularColor(const QColor& value);
-
- QColor emittedLight() const;
- void setEmittedLight(const QColor& value);
-
- void setColor(const QColor& value);
-
- qreal shininess() const;
- void setShininess(qreal value);
-
- QGLTexture2D *texture(int layer = 0) const;
- void setTexture(QGLTexture2D *value, int layer = 0);
-
- QUrl textureUrl(int layer = 0) const;
- void setTextureUrl(const QUrl &url, int layer = 0);
-
- enum TextureCombineMode
- {
- Modulate,
- Decal,
- Replace
- };
-
- QGLMaterial::TextureCombineMode textureCombineMode(int layer = 0) const;
- void setTextureCombineMode(QGLMaterial::TextureCombineMode mode, int layer = 0);
-
- int textureLayerCount() const;
-
- QGLMaterial *front() const;
- bool isTransparent() const;
- void bind(QGLPainter *painter);
- void release(QGLPainter *painter, QGLAbstractMaterial *next);
- void prepareToDraw(QGLPainter *painter, const QGLAttributeSet &attributes);
-
-Q_SIGNALS:
- void ambientColorChanged();
- void diffuseColorChanged();
- void specularColorChanged();
- void emittedLightChanged();
- void shininessChanged();
- void texturesChanged();
-
-private:
- friend class QGLMaterialCollection;
- friend class QGLTwoSidedMaterial;
-
- void bindTextures(QGLPainter *painter);
- void bindEffect(QGLPainter *painter, const QGLAttributeSet &attributes, bool twoSided);
-
- QScopedPointer<QGLMaterialPrivate> d_ptr;
-};
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLMaterial &material);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/materials/qglmaterial_p.h b/src/threed/materials/qglmaterial_p.h
deleted file mode 100644
index d935a40a..00000000
--- a/src/threed/materials/qglmaterial_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLMATERIAL_P_H
-#define QGLMATERIAL_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.
-//
-
-#include "qglmaterial.h"
-#include <QtCore/qmap.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLMaterialPrivate
-{
-public:
- explicit QGLMaterialPrivate();
-
- QColor ambientColor;
- QColor diffuseColor;
- QColor specularColor;
- QColor emittedLight;
- qreal shininess;
- QMap<int, QGLTexture2D *> textures;
- QMap<int, QGLMaterial::TextureCombineMode> textureModes;
- QGLMaterialCollection *collection;
- int index;
- QString name;
- bool used;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/materials/qgltwosidedmaterial.cpp b/src/threed/materials/qgltwosidedmaterial.cpp
deleted file mode 100644
index 0a1ee026..00000000
--- a/src/threed/materials/qgltwosidedmaterial.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgltwosidedmaterial.h"
-#include "qglpainter.h"
-#include "qgllightmodel.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLTwoSidedMaterial
- \since 4.8
- \brief The QGLTwoSidedMaterial class implemented two-sided materials for 3D rendering.
- \ingroup qt3d
- \ingroup qt3d::materials
-
- Two-sided materials consist of a front() material and a back()
- material. The specific material rendered is determined by the
- direction faced by a fragment when it is rendered. Fragments
- that point towards the viewer are rendered with front(),
- and fragments that point away from the viewer are rendered
- with back(). In both cases, any textures that are used to
- render the material are taken from front().
-
- If front() and back() are the same, then the same material
- will be used on both sides of the fragment. However, this
- is not exactly the same as using a one-sided QGLMaterial in
- place of the two-sided material. One-sided materials will
- render the back of the fragment as black because the normal
- is always pointing away from the viewer. Two-sided materials
- reverse the back-facing normal so that back() is lit as
- though it was on a front-facing face.
-
- \sa QGLMaterial
-*/
-
-class QGLTwoSidedMaterialPrivate
-{
-public:
- QGLTwoSidedMaterialPrivate() : front(0), back(0), defaultMaterial(0) {}
-
- QGLMaterial *front;
- QGLMaterial *back;
- QGLMaterial *defaultMaterial;
-};
-
-/*!
- Constructs a two-sided material object and attaches it to \a parent.
-
- \sa setFront(), setBack()
-*/
-QGLTwoSidedMaterial::QGLTwoSidedMaterial(QObject *parent)
- : QGLAbstractMaterial(parent)
- , d_ptr(new QGLTwoSidedMaterialPrivate)
-{
-}
-
-/*!
- Destroys this two-sided material object.
-*/
-QGLTwoSidedMaterial::~QGLTwoSidedMaterial()
-{
-}
-
-/*!
- \property QGLTwoSidedMaterial::front
- \brief the material for the front side of the object's fragments.
-
- The default value is null, which will result in a default QGLMaterial
- object being used when bind() is called.
-
- \sa back(), frontChanged(), materialChanged()
-*/
-
-QGLMaterial *QGLTwoSidedMaterial::front() const
-{
- Q_D(const QGLTwoSidedMaterial);
- return d->front;
-}
-
-void QGLTwoSidedMaterial::setFront(QGLMaterial *material)
-{
- Q_D(QGLTwoSidedMaterial);
- if (d->front != material) {
- if (d->front && d->front != d->back) {
- disconnect(d->front, SIGNAL(materialChanged()),
- this, SIGNAL(materialChanged()));
- }
- d->front = material;
- if (d->front && d->front != d->back) {
- connect(d->front, SIGNAL(materialChanged()),
- this, SIGNAL(materialChanged()));
- }
- emit frontChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \property QGLTwoSidedMaterial::back
- \brief the material for the back side of the object's fragments.
-
- The default value is null, which indicates that front() should
- be used on both the front and back sides of the object's fragments.
-
- Textures are taken from the front() material. Any textures that
- appear in the back() material are ignored. Only the material
- lighting parameters from back() will be used.
-
- \sa front(), backChanged(), materialChanged()
-*/
-
-QGLMaterial *QGLTwoSidedMaterial::back() const
-{
- Q_D(const QGLTwoSidedMaterial);
- return d->back;
-}
-
-void QGLTwoSidedMaterial::setBack(QGLMaterial *material)
-{
- Q_D(QGLTwoSidedMaterial);
- if (d->back != material) {
- if (d->back && d->back != d->front) {
- disconnect(d->back, SIGNAL(materialChanged()),
- this, SIGNAL(materialChanged()));
- }
- d->back = material;
- if (d->back && d->back != d->front) {
- connect(d->back, SIGNAL(materialChanged()),
- this, SIGNAL(materialChanged()));
- }
- emit backChanged();
- emit materialChanged();
- }
-}
-
-/*!
- \reimp
-*/
-bool QGLTwoSidedMaterial::isTransparent() const
-{
- Q_D(const QGLTwoSidedMaterial);
- if (d->front && d->front->isTransparent())
- return true;
- return d->back && d->back->isTransparent();
-}
-
-/*!
- \reimp
-*/
-void QGLTwoSidedMaterial::bind(QGLPainter *painter)
-{
- Q_D(QGLTwoSidedMaterial);
- QGLMaterial *front = d->front;
- if (!front) {
- // We need to have something for the front material.
- front = d->defaultMaterial;
- if (!front) {
- d->defaultMaterial = new QGLMaterial(this);
- front = d->defaultMaterial;
- }
- }
- const_cast<QGLLightModel *>(painter->lightModel())
- ->setModel(QGLLightModel::TwoSided); // FIXME
- if (d->back && d->back != front) {
- painter->setFaceMaterial(QGL::FrontFaces, front);
- painter->setFaceMaterial(QGL::BackFaces, d->back);
- } else {
- painter->setFaceMaterial(QGL::AllFaces, front);
- }
- front->bindTextures(painter);
-}
-
-/*!
- \reimp
-*/
-void QGLTwoSidedMaterial::release(QGLPainter *painter, QGLAbstractMaterial *next)
-{
- Q_D(const QGLTwoSidedMaterial);
- if (d->front)
- d->front->release(painter, next);
- else if (d->defaultMaterial)
- d->defaultMaterial->release(painter, next);
-}
-
-/*!
- \reimp
-*/
-void QGLTwoSidedMaterial::prepareToDraw
- (QGLPainter *painter, const QGLAttributeSet &attributes)
-{
- Q_D(QGLTwoSidedMaterial);
- QGLMaterial *front = d->front;
- if (!front)
- front = d->defaultMaterial;
- front->bindEffect(painter, attributes, true);
-}
-
-/*!
- \fn void QGLTwoSidedMaterial::frontChanged()
-
- Signal that is emitted when the front() material pointer changes.
-
- This signal is not emitted when a property on front() changes.
- Use materialChanged() for that purpose instead.
-
- \sa front(), backChanged()
-*/
-
-/*!
- \fn void QGLTwoSidedMaterial::backChanged()
-
- Signal that is emitted when the back() material pointer changes.
-
- This signal is not emitted when a property on back() changes.
- Use materialChanged() for that purpose instead.
-
- \sa back(), frontChanged()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/materials/qgltwosidedmaterial.h b/src/threed/materials/qgltwosidedmaterial.h
deleted file mode 100644
index acba2451..00000000
--- a/src/threed/materials/qgltwosidedmaterial.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTWOSIDEDMATERIAL_H
-#define QGLTWOSIDEDMATERIAL_H
-
-#include "qglmaterial.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLTwoSidedMaterialPrivate;
-
-class Q_QT3D_EXPORT QGLTwoSidedMaterial : public QGLAbstractMaterial
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLTwoSidedMaterial)
- Q_DISABLE_COPY(QGLTwoSidedMaterial)
- Q_PROPERTY(QGLMaterial *front READ front WRITE setFront NOTIFY frontChanged)
- Q_PROPERTY(QGLMaterial *back READ back WRITE setBack NOTIFY backChanged)
-public:
- explicit QGLTwoSidedMaterial(QObject *parent = 0);
- ~QGLTwoSidedMaterial();
-
- QGLMaterial *front() const;
- void setFront(QGLMaterial *material);
-
- QGLMaterial *back() const;
- void setBack(QGLMaterial *material);
-
- bool isTransparent() const;
- void bind(QGLPainter *painter);
- void release(QGLPainter *painter, QGLAbstractMaterial *next);
- void prepareToDraw(QGLPainter *painter, const QGLAttributeSet &attributes);
-
-Q_SIGNALS:
- void frontChanged();
- void backChanged();
-
-private:
- QScopedPointer<QGLTwoSidedMaterialPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/math3d/math3d.pri b/src/threed/math3d/math3d.pri
deleted file mode 100644
index 0d36db90..00000000
--- a/src/threed/math3d/math3d.pri
+++ /dev/null
@@ -1,12 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += math3d/qbox3d.h \
- math3d/qplane3d.h \
- math3d/qray3d.h \
- math3d/qsphere3d.h \
- math3d/qtriangle3d.h
-SOURCES += qbox3d.cpp \
- qplane3d.cpp \
- qray3d.cpp \
- qsphere3d.cpp \
- qtriangle3d.cpp
diff --git a/src/threed/math3d/qbox3d.cpp b/src/threed/math3d/qbox3d.cpp
deleted file mode 100644
index a1603c84..00000000
--- a/src/threed/math3d/qbox3d.cpp
+++ /dev/null
@@ -1,690 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qbox3d.h"
-#include "qplane3d.h"
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qlist.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QBox3D
- \brief The QBox3D class represents an axis-aligned box in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::math
-
- QBox3D can be used to represent the bounding box of objects in a 3D
- scene so that they can be easily culled if they are out of view.
-
- The sides of the box are always aligned with the x, y, and z axes of
- the world co-ordinate system. Transforming a box with transformed()
- will result in the smallest axis-aligned bounding box that contains
- the transformed box.
-
- Boxes may be null, finite, or infinite. A null box does not occupy
- any space and does not intersect with any other box. A finite
- box consists of a minimum() and maximum() extent in 3D space.
- An infinite box encompasses all points in 3D space.
-
- The extents of a finite box are also included within the box.
- A box with minimum() and maximum() set to the same value
- contains a single point.
-*/
-
-/*!
- \fn QBox3D::QBox3D()
-
- Constructs a null box in 3D space.
-
- \sa isNull()
-*/
-
-/*!
- \fn QBox3D::QBox3D(const QVector3D& corner1, const QVector3D& corner2)
-
- Constructs a finite box in 3D space from \a corner1 to \a corner2.
- The minimum() and maximum() co-ordinates of the new box are set
- to the minimum and maximum x, y, and z values from \a corner1 and
- \a corner2. The \a corner1 and \a corner2 values can be any two
- opposite corners that define the box.
-
- \sa isFinite(), minimum(), maximum()
-*/
-
-/*!
- \fn bool QBox3D::isNull() const
-
- Returns true if this box is null; false otherwise.
-
- \sa isFinite(), isInfinite(), setToNull()
-*/
-
-/*!
- \fn bool QBox3D::isFinite() const
-
- Returns true if this box is finite in size; false otherwise.
-
- \sa isNull(), isInfinite(), setExtents()
-*/
-
-/*!
- \fn bool QBox3D::isInfinite() const
-
- Returns true if this box is infinite in size; false otherwise.
-
- \sa isNull(), isFinite(), setToInfinite()
-*/
-
-/*!
- \fn QVector3D QBox3D::minimum() const
-
- Returns the minimum corner of this box.
-
- \sa maximum(), setExtents()
-*/
-
-/*!
- \fn QVector3D QBox3D::maximum() const
-
- Returns the maximum corner of this box.
-
- \sa minimum(), setExtents()
-*/
-
-/*!
- \fn void QBox3D::setExtents(const QVector3D& corner1, const QVector3D& corner2)
-
- Sets the extents of this box to a finite region from \a corner1 to
- \a corner2. The minimum() and maximum() co-ordinates of the box are
- set to the minimum and maximum x, y, and z values from \a corner1 and
- \a corner2. The \a corner1 and \a corner2 values can be any two
- opposite corners that define the box.
-
- \sa minimum(), maximum()
-*/
-
-/*!
- \fn void QBox3D::setToNull()
-
- Sets this box to null.
-
- \sa isNull()
-*/
-
-/*!
- \fn void QBox3D::setToInfinite()
-
- Sets this box to be infinite in size.
-
- \sa isInfinite()
-*/
-
-/*!
- \fn QVector3D QBox3D::size() const
-
- Returns the finite size of this box. If this box is null or
- infinite, the returned value will be zero.
-
- \sa center(), isNull(), isInfinite()
-*/
-
-/*!
- \fn QVector3D QBox3D::center() const
-
- Returns the finite center of this box. If this box is null
- or infinite, the returned value will be zero.
-
- \sa size(), isNull(), isInfinite()
-*/
-
-/*!
- \fn bool QBox3D::contains(const QVector3D& point) const
-
- Returns true if this box contains \a point; false otherwise.
- Null boxes do not contain any points and infinite boxes contain
- all points.
-
- Containment is not a strict test: the point is contained if it
- lies on one of the faces of the box.
-
- \sa intersects()
-*/
-
-/*!
- \fn bool QBox3D::contains(const QBox3D& box) const
-
- Returns true if this box completely contains \a box. If this box
- is null, then it will not contain \a box. If this box is infinite,
- and \a box is not null, then \a box will be contained within this box.
- If \a box is infinite, then this box must also be infinite to contain it.
-
- \sa intersects()
-*/
-
-/*!
- Returns true if \a box intersects this box; false otherwise.
-
- \sa intersect(), intersected(), contains()
-*/
-bool QBox3D::intersects(const QBox3D& box) const
-{
- if (boxtype == Null)
- return false;
- else if (boxtype == Infinite)
- return box.boxtype != Null;
- else if (box.boxtype == Null)
- return false;
- else if (box.boxtype == Infinite)
- return true;
-
- if (maxcorner.x() < box.mincorner.x())
- return false;
- if (mincorner.x() > box.maxcorner.x())
- return false;
-
- if (maxcorner.y() < box.mincorner.y())
- return false;
- if (mincorner.y() > box.maxcorner.y())
- return false;
-
- if (maxcorner.z() < box.mincorner.z())
- return false;
- if (mincorner.z() > box.maxcorner.z())
- return false;
-
- return true;
-}
-
-/*!
- Returns true if \a ray intersects this box; false otherwise.
-
- \sa intersection()
-*/
-bool QBox3D::intersects(const QRay3D &ray) const
-{
- qreal minimum_t, maximum_t;
- return intersection(ray, &minimum_t, &maximum_t);
-}
-
-static inline void trackIntersectionX
- (const QBox3D &box, const QRay3D &ray, qreal t,
- qreal *minimum_t, qreal *maximum_t, bool *found)
-{
- QVector3D point = ray.point(t);
- if (point.y() < box.minimum().y() || point.y() > box.maximum().y())
- return;
- if (point.z() < box.minimum().z() || point.z() > box.maximum().z())
- return;
- if (!(*found)) {
- *minimum_t = *maximum_t = t;
- *found = true;
- } else {
- if (t < *minimum_t)
- *minimum_t = t;
- if (t > *maximum_t)
- *maximum_t = t;
- }
-}
-
-static inline void trackIntersectionY
- (const QBox3D &box, const QRay3D &ray, qreal t,
- qreal *minimum_t, qreal *maximum_t, bool *found)
-{
- QVector3D point = ray.point(t);
- if (point.x() < box.minimum().x() || point.x() > box.maximum().x())
- return;
- if (point.z() < box.minimum().z() || point.z() > box.maximum().z())
- return;
- if (!(*found)) {
- *minimum_t = *maximum_t = t;
- *found = true;
- } else {
- if (t < *minimum_t)
- *minimum_t = t;
- if (t > *maximum_t)
- *maximum_t = t;
- }
-}
-
-static inline void trackIntersectionZ
- (const QBox3D &box, const QRay3D &ray, qreal t,
- qreal *minimum_t, qreal *maximum_t, bool *found)
-{
- QVector3D point = ray.point(t);
- if (point.x() < box.minimum().x() || point.x() > box.maximum().x())
- return;
- if (point.y() < box.minimum().y() || point.y() > box.maximum().y())
- return;
- if (!(*found)) {
- *minimum_t = *maximum_t = t;
- *found = true;
- } else {
- if (t < *minimum_t)
- *minimum_t = t;
- if (t > *maximum_t)
- *maximum_t = t;
- }
-}
-
-/*!
- Finds the \a minimum_t and \a maximum_t values where \a ray intersects
- this box. Returns true if intersections were found; or false if there
- is no intersection.
-
- If \a minimum_t and \a maximum_t are set to the same value, then the
- intersection is at a corner or the volume of the box is zero.
- If the t values are negative, then the intersection occurs before the
- ray's origin point in the reverse direction of the ray.
-
- The \a minimum_t and \a maximum_t values can be passed to QRay3D::point()
- to determine the actual intersection points, as shown in the following
- example:
-
- \code
- qreal minimum_t, maximum_t;
- if (box.intersection(ray, &minimum_t, &maximum_t)) {
- qDebug() << "intersections at"
- << ray.point(minimum_t) << "and"
- << ray.point(maximum_t);
- }
- \endcode
-
- \sa intersects(), QRay3D::point()
-*/
-bool QBox3D::intersection(const QRay3D &ray, qreal *minimum_t, qreal *maximum_t) const
-{
- bool found = false;
- QVector3D origin = ray.origin();
- QVector3D direction = ray.direction();
- *minimum_t = *maximum_t = qSNaN();
- if (boxtype == Finite) {
- if (direction.x() != 0.0f) {
- trackIntersectionX
- (*this, ray, (mincorner.x() - origin.x()) / direction.x(),
- minimum_t, maximum_t, &found);
- trackIntersectionX
- (*this, ray, (maxcorner.x() - origin.x()) / direction.x(),
- minimum_t, maximum_t, &found);
- }
- if (direction.y() != 0.0f) {
- trackIntersectionY
- (*this, ray, (mincorner.y() - origin.y()) / direction.y(),
- minimum_t, maximum_t, &found);
- trackIntersectionY
- (*this, ray, (maxcorner.y() - origin.y()) / direction.y(),
- minimum_t, maximum_t, &found);
- }
- if (direction.z() != 0.0f) {
- trackIntersectionZ
- (*this, ray, (mincorner.z() - origin.z()) / direction.z(),
- minimum_t, maximum_t, &found);
- trackIntersectionZ
- (*this, ray, (maxcorner.z() - origin.z()) / direction.z(),
- minimum_t, maximum_t, &found);
- }
- }
- return found;
-}
-
-/*!
- Returns the t value at which \a ray first intersects the sides of
- this box, or not-a-number if there is no intersection.
-
- When the \a ray intersects this box, the return value is a
- parametric value that can be passed to QRay3D::point() to determine
- the actual intersection point, as shown in the following example:
-
- \code
- qreal t = box.intersection(ray);
- QVector3D pt;
- if (qIsNaN(t)) {
- qWarning("no intersection occurred");
- else
- pt = ray.point(t);
- \endcode
-
- The \a ray might intersect at two points - as the ray passes through
- the box - one on the near side, one on the far side; where near and far
- are relative to the origin point of the ray. This function only
- returns the near intersection point.
-
- Only positive values on the ray are considered. This means that if
- the origin point of the ray is inside the box, there is only one
- solution, not two. To get the other solution, simply change
- the sign of the ray's direction vector. If the origin point of
- the ray is outside the box, and the direction points away from
- the box, then there will be no intersection.
-
- When the ray does not intersect the box in the positive direction,
- or the box is not finite, then the return value is not-a-number.
-
- \sa intersects(), QRay3D::point()
-*/
-qreal QBox3D::intersection(const QRay3D &ray) const
-{
- qreal minimum_t, maximum_t;
- if (intersection(ray, &minimum_t, &maximum_t)) {
- if (minimum_t >= 0.0f)
- return minimum_t;
- else if (maximum_t >= 0.0f)
- return maximum_t;
- else
- return qSNaN();
- } else {
- return qSNaN();
- }
-}
-
-/*!
- Intersects this box with \a box.
-
- \sa intersected(), intersects(), unite()
-*/
-void QBox3D::intersect(const QBox3D& box)
-{
- // Handle the simple cases first.
- if (boxtype == Null) {
- // Null intersected with anything is null.
- return;
- } else if (boxtype == Infinite) {
- // Infinity intersected with a box is that box.
- *this = box;
- return;
- } else if (box.boxtype == Null) {
- // Anything intersected with null is null.
- setToNull();
- return;
- } else if (box.boxtype == Infinite) {
- // Box intersected with infinity is the box.
- return;
- }
-
- // Intersect two finite boxes.
- QVector3D min1 = mincorner;
- QVector3D max1 = maxcorner;
- QVector3D min2 = box.mincorner;
- QVector3D max2 = box.maxcorner;
- if (min2.x() > min1.x())
- min1.setX(min2.x());
- if (min2.y() > min1.y())
- min1.setY(min2.y());
- if (min2.z() > min1.z())
- min1.setZ(min2.z());
- if (max2.x() < max1.x())
- max1.setX(max2.x());
- if (max2.y() < max1.y())
- max1.setY(max2.y());
- if (max2.z() < max1.z())
- max1.setZ(max2.z());
- if (min1.x() > max1.x() || min1.y() > max1.y() || min1.z() > max1.z()) {
- setToNull();
- } else {
- mincorner = min1;
- maxcorner = max1;
- }
-}
-
-/*!
- Returns a new box which is the intersection of this box with \a box.
-
- \sa intersect(), intersects(), united()
-*/
-QBox3D QBox3D::intersected(const QBox3D& box) const
-{
- QBox3D result(*this);
- result.intersect(box);
- return result;
-}
-
-/*!
- Unites this box with \a point by expanding it to encompass \a point.
- If \a point is already contained within this box, then this box
- will be unchanged.
-
- \sa united(), intersect()
-*/
-void QBox3D::unite(const QVector3D& point)
-{
- if (boxtype == Finite) {
- if (point.x() < mincorner.x())
- mincorner.setX(point.x());
- else if (point.x() > maxcorner.x())
- maxcorner.setX(point.x());
- if (point.y() < mincorner.y())
- mincorner.setY(point.y());
- else if (point.y() > maxcorner.y())
- maxcorner.setY(point.y());
- if (point.z() < mincorner.z())
- mincorner.setZ(point.z());
- else if (point.z() > maxcorner.z())
- maxcorner.setZ(point.z());
- } else if (boxtype == Null) {
- boxtype = Finite;
- mincorner = point;
- maxcorner = point;
- }
-}
-
-/*!
- Unites this box with \a box by expanding this box to encompass the
- region defined by \a box. If \a box is already contained within
- this box, then this box will be unchanged.
-
- \sa united(), intersect()
-*/
-void QBox3D::unite(const QBox3D& box)
-{
- if (box.boxtype == Finite) {
- unite(box.minimum());
- unite(box.maximum());
- } else if (box.boxtype == Infinite) {
- setToInfinite();
- }
-}
-
-/*!
- Returns a new box which unites this box with \a point. The returned
- value will be the smallest box that contains both this box and \a point.
-
- \sa unite(), intersected()
-*/
-QBox3D QBox3D::united(const QVector3D& point) const
-{
- if (boxtype == Finite) {
- QBox3D result(*this);
- result.unite(point);
- return result;
- } else if (boxtype == Null) {
- return QBox3D(point, point);
- } else {
- return *this;
- }
-}
-
-/*!
- Returns a new box which unites this box with \a box. The returned value
- will be the smallest box that contains both this box and \a box.
-
- \sa unite(), intersected()
-*/
-QBox3D QBox3D::united(const QBox3D& box) const
-{
- if (boxtype == Finite) {
- QBox3D result(*this);
- result.unite(box);
- return result;
- } else if (boxtype == Null) {
- return box;
- } else {
- return *this;
- }
-}
-
-/*!
- Transforms this box according to \a matrix. Each of the 8 box
- corners are transformed and then a new box that encompasses all
- of the transformed corner values is created.
-
- \sa transformed()
-*/
-void QBox3D::transform(const QMatrix4x4& matrix)
-{
- *this = transformed(matrix);
-}
-
-/*!
- Returns this box transformed by \a matrix. Each of the 8 box
- corners are transformed and then a new box that encompasses all
- of the transformed corner values is returned.
-
- \sa transform()
-*/
-QBox3D QBox3D::transformed(const QMatrix4x4& matrix) const
-{
- if (boxtype != Finite)
- return *this;
- QBox3D result;
- result.unite(matrix * mincorner);
- result.unite(matrix * QVector3D(mincorner.x(), mincorner.y(), maxcorner.z()));
- result.unite(matrix * QVector3D(mincorner.x(), maxcorner.y(), maxcorner.z()));
- result.unite(matrix * QVector3D(mincorner.x(), maxcorner.y(), mincorner.z()));
- result.unite(matrix * QVector3D(maxcorner.x(), mincorner.y(), mincorner.z()));
- result.unite(matrix * QVector3D(maxcorner.x(), maxcorner.y(), mincorner.z()));
- result.unite(matrix * QVector3D(maxcorner.x(), mincorner.y(), maxcorner.z()));
- result.unite(matrix * maxcorner);
- return result;
-}
-
-/*!
- \fn bool QBox3D::operator==(const QBox3D& box) const
-
- Returns true if this box is identical to \a box.
-*/
-
-/*!
- \fn bool QBox3D::operator!=(const QBox3D& box) const
-
- Returns true if this box is not identical to \a box.
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QBox3D& box1, const QBox3D& box2)
- \relates QBox3D
-
- Returns true if \a box1 and \a box2 are almost equal; false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QBox3D &box)
-{
- if (box.isFinite()) {
- dbg.nospace() << "QBox3D(("
- << box.minimum().x() << ", " << box.minimum().y() << ", "
- << box.minimum().z() << ") - ("
- << box.maximum().x() << ", " << box.maximum().y() << ", "
- << box.maximum().z() << "))";
- return dbg.space();
- } else if (box.isNull()) {
- dbg << "QBox3D(null)";
- return dbg;
- } else {
- dbg << "QBox3D(infinite)";
- return dbg;
- }
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QBox3D &box)
- \relates QBox3D
-
- Writes the given \a box to the given \a stream and returns a
- reference to the stream.
-*/
-
-QDataStream &operator<<(QDataStream &stream, const QBox3D &box)
-{
- if (box.isNull()) {
- stream << int(0);
- } else if (box.isInfinite()) {
- stream << int(2);
- } else {
- stream << int(1);
- stream << box.minimum();
- stream << box.maximum();
- }
- return stream;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QBox3D &box)
- \relates QBox3D
-
- Reads a 3D box from the given \a stream into the given \a box
- and returns a reference to the stream.
-*/
-
-QDataStream &operator>>(QDataStream &stream, QBox3D &box)
-{
- int type;
- stream >> type;
- if (type == 1) {
- QVector3D minimum, maximum;
- stream >> minimum;
- stream >> maximum;
- box = QBox3D(minimum, maximum);
- } else if (type == 2) {
- box.setToInfinite();
- } else {
- box.setToNull();
- }
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/threed/math3d/qbox3d.h b/src/threed/math3d/qbox3d.h
deleted file mode 100644
index c4e1f012..00000000
--- a/src/threed/math3d/qbox3d.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QBOX3D_H
-#define QBOX3D_H
-
-#include "qt3dglobal.h"
-#include "qray3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QBox3D
-{
-public:
- QBox3D();
- QBox3D(const QVector3D& corner1, const QVector3D& corner2);
-
- bool isNull() const;
- bool isFinite() const;
- bool isInfinite() const;
-
- QVector3D minimum() const;
- QVector3D maximum() const;
- void setExtents(const QVector3D& corner1, const QVector3D& corner2);
-
- void setToNull();
- void setToInfinite();
-
- QVector3D size() const;
- QVector3D center() const;
-
- bool contains(const QVector3D& point) const;
- bool contains(const QBox3D& box) const;
-
- bool intersects(const QRay3D& ray) const;
- bool intersection(const QRay3D &ray, qreal *minimum_t, qreal *maximum_t) const;
- qreal intersection(const QRay3D& ray) const;
-
- bool intersects(const QBox3D& box) const;
- void intersect(const QBox3D& box);
- QBox3D intersected(const QBox3D& box) const;
-
- void unite(const QVector3D& point);
- void unite(const QBox3D& box);
-
- QBox3D united(const QVector3D& point) const;
- QBox3D united(const QBox3D& box) const;
-
- void transform(const QMatrix4x4& matrix);
- QBox3D transformed(const QMatrix4x4& matrix) const;
-
- bool operator==(const QBox3D& box) const;
- bool operator!=(const QBox3D& box) const;
-
- friend bool qFuzzyCompare(const QBox3D& box1, const QBox3D& box2);
-
-private:
- enum Type
- {
- Null,
- Finite,
- Infinite
- };
-
- QBox3D::Type boxtype;
- QVector3D mincorner, maxcorner;
-};
-
-inline QBox3D::QBox3D() : boxtype(Null), mincorner(0, 0, 0), maxcorner(0, 0, 0) {}
-
-inline QBox3D::QBox3D(const QVector3D& corner1, const QVector3D& corner2)
- : boxtype(Finite),
- mincorner(qMin(corner1.x(), corner2.x()),
- qMin(corner1.y(), corner2.y()),
- qMin(corner1.z(), corner2.z())),
- maxcorner(qMax(corner1.x(), corner2.x()),
- qMax(corner1.y(), corner2.y()),
- qMax(corner1.z(), corner2.z())) {}
-
-inline bool QBox3D::isNull() const { return (boxtype == Null); }
-inline bool QBox3D::isFinite() const { return (boxtype == Finite); }
-inline bool QBox3D::isInfinite() const { return (boxtype == Infinite); }
-
-inline QVector3D QBox3D::minimum() const { return mincorner; }
-inline QVector3D QBox3D::maximum() const { return maxcorner; }
-
-inline void QBox3D::setExtents(const QVector3D& corner1, const QVector3D& corner2)
-{
- boxtype = Finite;
- mincorner = QVector3D(qMin(corner1.x(), corner2.x()),
- qMin(corner1.y(), corner2.y()),
- qMin(corner1.z(), corner2.z()));
- maxcorner = QVector3D(qMax(corner1.x(), corner2.x()),
- qMax(corner1.y(), corner2.y()),
- qMax(corner1.z(), corner2.z()));
-}
-
-inline void QBox3D::setToNull()
-{
- boxtype = Null;
- mincorner = QVector3D(0, 0, 0);
- maxcorner = QVector3D(0, 0, 0);
-}
-
-inline void QBox3D::setToInfinite()
-{
- boxtype = Infinite;
- mincorner = QVector3D(0, 0, 0);
- maxcorner = QVector3D(0, 0, 0);
-}
-
-inline QVector3D QBox3D::size() const { return maxcorner - mincorner; }
-inline QVector3D QBox3D::center() const { return (mincorner + maxcorner) * 0.5f; }
-
-inline bool QBox3D::contains(const QVector3D& point) const
-{
- if (boxtype == Finite) {
- return (point.x() >= mincorner.x() && point.x() <= maxcorner.x() &&
- point.y() >= mincorner.y() && point.y() <= maxcorner.y() &&
- point.z() >= mincorner.z() && point.z() <= maxcorner.z());
- } else if (boxtype == Infinite) {
- return true;
- } else {
- return false;
- }
-}
-
-inline bool QBox3D::contains(const QBox3D& box) const
-{
- if (box.boxtype == Finite)
- return contains(box.mincorner) && contains(box.maxcorner);
- else if (box.boxtype == Infinite)
- return (boxtype == Infinite);
- else
- return false;
-}
-
-inline bool QBox3D::operator==(const QBox3D& box) const
-{
- return (boxtype == box.boxtype &&
- mincorner == box.mincorner &&
- maxcorner == box.maxcorner);
-}
-
-inline bool QBox3D::operator!=(const QBox3D& box) const
-{
- return (boxtype != box.boxtype ||
- mincorner != box.mincorner ||
- maxcorner != box.maxcorner);
-}
-
-inline bool qFuzzyCompare(const QBox3D& box1, const QBox3D& box2)
-{
- return box1.boxtype == box2.boxtype &&
- qFuzzyCompare(box1.mincorner, box2.mincorner) &&
- qFuzzyCompare(box1.maxcorner, box2.maxcorner);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QBox3D &box);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_QT3D_EXPORT QDataStream &operator<<(QDataStream &stream, const QBox3D &box);
-Q_QT3D_EXPORT QDataStream &operator>>(QDataStream &stream, QBox3D &box);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QBox3D)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/math3d/qplane3d.cpp b/src/threed/math3d/qplane3d.cpp
deleted file mode 100644
index ec324c0e..00000000
--- a/src/threed/math3d/qplane3d.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qplane3d.h"
-#include <QtCore/qmath.h>
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QPlane3D
- \brief The QPlane3D class models the mathematics of planes in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::math
-
- A plane is defined by an origin() point lying on the plane, and a
- normal() vector, which is perpendicular to the surface of the plane.
- The normal() vector does not need to be normalized. QPlane3D is an
- infinite surface, from which the normal() vector points out perpendicular
- from the origin() point.
-
- \sa QRay3D
-*/
-
-/*!
- \fn QPlane3D::QPlane3D()
-
- Constructs a default plane object. The defining origin() of the plane
- is set to (0, 0, 0) and the normal() vector is to (1, 0, 0).
-*/
-
-/*!
- \fn QPlane3D::QPlane3D(const QVector3D &point, const QVector3D &normal)
-
- Constructs a new plane, where \a point lies on the plane, and \a normal
- is perpendicular to it. The \a normal does not have to be normalized.
- If \a normal is zero, the behavior of the plane is undefined.
-*/
-
-/*!
- \fn QPlane3D::QPlane3D(const QVector3D &p, const QVector3D &q, const QVector3D &r)
-
- Constructs a new plane defined by the three points \a p, \a q, and \a r.
- The point \a p is used as the plane's origin() point, and a normal()
- is constructed from the cross-product of \a q - \a p and \a r - \a q.
-*/
-
-/*!
- \fn QVector3D QPlane3D::origin() const
-
- Returns this plane's defining origin point. The default value is (0, 0, 0).
-
- \sa setOrigin(), normal()
-*/
-
-/*!
- \fn void QPlane3D::setOrigin(const QVector3D& value)
-
- Set this plane's defining origin point to \a value.
-
- \sa origin(), setNormal()
-*/
-
-/*!
- \fn QVector3D QPlane3D::normal() const
-
- Returns this plane's normal vector. The default value is (1, 0, 0).
-
- \sa setNormal(), origin()
-*/
-
-/*!
- \fn void QPlane3D::setNormal(const QVector3D& value)
-
- Set this plane's normal vector to \a value. The \a value does
- not have to be normalized. If \a value is zero, the behavior
- of the plane is undefined.
-
- \sa normal(), setOrigin()
-*/
-
-/*!
- Returns true if \a point lies in this plane; false otherwise.
-*/
-bool QPlane3D::contains(const QVector3D &point) const
-{
- return qFuzzyIsNull
- (float(QVector3D::dotProduct(m_normal, m_origin - point)));
-}
-
-/*!
- Returns true if all of the points on \a ray lie in this plane;
- false otherwise.
-*/
-bool QPlane3D::contains(const QRay3D &ray) const
-{
- return qFuzzyIsNull
- (float(QVector3D::dotProduct(m_normal, ray.direction()))) &&
- contains(ray.origin());
-}
-
-/*!
- Returns true if an intersection of \a ray with this plane exists;
- false otherwise.
-
- \sa intersection()
-*/
-bool QPlane3D::intersects(const QRay3D &ray) const
-{
- return !qFuzzyIsNull
- (float(QVector3D::dotProduct(m_normal, ray.direction())));
-}
-
-/*!
- Returns the t value at which \a ray intersects this plane, or
- not-a-number if there is no intersection.
-
- When the \a ray intersects this plane, the return value is a
- parametric value that can be passed to QRay3D::point() to determine
- the actual intersection point, as shown in the following example:
-
- \code
- qreal t = plane.intersection(ray);
- QVector3D pt;
- if (qIsNaN(t)) {
- qWarning("no intersection occurred");
- else
- pt = ray.point(t);
- \endcode
-
- If the return value is positive, then the QRay3D::origin() of
- \a ray begins below the plane and then extends through it.
- If the return value is negative, then the origin begins
- above the plane.
-
- There are two failure cases where no single intersection point exists:
-
- \list
- \o when the ray is parallel to the plane (but does not lie on it)
- \o the ray lies entirely in the plane (thus every point "intersects")
- \endlist
-
- This method does not distinguish between these two failure cases and
- simply returns not-a-number for both.
-
- \sa intersects()
-*/
-qreal QPlane3D::intersection(const QRay3D& ray) const
-{
- qreal dotLineAndPlane = QVector3D::dotProduct(m_normal, ray.direction());
- if (qFuzzyIsNull(float(dotLineAndPlane))) {
- // degenerate case - ray & plane-normal vectors are at
- // 90 degrees to each other, so either plane and ray never meet
- // or the ray lies in the plane - return failure case.
- return qSNaN();
- }
- return QVector3D::dotProduct(m_origin - ray.origin(), m_normal) /
- dotLineAndPlane;
-}
-
-/*!
- Returns the distance from this plane to \a point. The value will
- be positive if \a point is above the plane in the direction
- of normal(), and negative if \a point is below the plane.
-*/
-qreal QPlane3D::distanceTo(const QVector3D &point) const
-{
- return QVector3D::dotProduct(point - m_origin, m_normal) /
- m_normal.length();
-}
-
-/*!
- \fn void QPlane3D::transform(const QMatrix4x4 &matrix)
-
- Transforms this plane using \a matrix, replacing origin() and
- normal() with the transformed versions.
-
- \sa transformed()
-*/
-
-/*!
- \fn QPlane3D QPlane3D::transformed(const QMatrix4x4 &matrix) const
-
- Returns a new plane that is formed by transforming origin()
- and normal() using \a matrix.
-
- \sa transform()
-*/
-
-/*!
- \fn bool QPlane3D::operator==(const QPlane3D &other)
-
- Returns true if this plane is the same as \a other; false otherwise.
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QPlane3D::operator!=(const QPlane3D &other)
-
- Returns true if this plane is not the same as \a other; false otherwise.
-
- \sa operator==()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QPlane3D &plane1, const QPlane3D &plane2)
- \relates QPlane3D
-
- Returns true if \a plane1 and \a plane2 are almost equal; false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QPlane3D &plane)
-{
- dbg.nospace() << "QPlane3D(origin("
- << plane.origin().x() << ", " << plane.origin().y() << ", "
- << plane.origin().z() << ") - normal("
- << plane.normal().x() << ", " << plane.normal().y() << ", "
- << plane.normal().z() << "))";
- return dbg.space();
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QPlane3D &plane)
- \relates QPlane3D
-
- Writes the given \a plane to the given \a stream and returns a
- reference to the stream.
-*/
-
-QDataStream &operator<<(QDataStream &stream, const QPlane3D &plane)
-{
- stream << plane.origin();
- stream << plane.normal();
- return stream;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QPlane3D &plane)
- \relates QPlane3D
-
- Reads a 3D plane from the given \a stream into the given \a plane
- and returns a reference to the stream.
-*/
-
-QDataStream &operator>>(QDataStream &stream, QPlane3D &plane)
-{
- QVector3D origin, normal;
- stream >> origin;
- stream >> normal;
- plane = QPlane3D(origin, normal);
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/threed/math3d/qplane3d.h b/src/threed/math3d/qplane3d.h
deleted file mode 100644
index bd8f5f6f..00000000
--- a/src/threed/math3d/qplane3d.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QPLANE3D_H
-#define QPLANE3D_H
-
-#include <QtGui/qvector3d.h>
-#include <QtCore/qnumeric.h>
-#include "qray3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QPlane3D
-{
-public:
- QPlane3D();
- QPlane3D(const QVector3D &point, const QVector3D &normal);
- QPlane3D(const QVector3D &p, const QVector3D &q, const QVector3D &r);
-
- QVector3D origin() const;
- void setOrigin(const QVector3D& value);
-
- QVector3D normal() const;
- void setNormal(const QVector3D& value);
-
- bool contains(const QVector3D &point) const;
- bool contains(const QRay3D &ray) const;
-
- bool intersects(const QRay3D &ray) const;
- qreal intersection(const QRay3D &ray) const;
-
- qreal distanceTo(const QVector3D &point) const;
-
- void transform(const QMatrix4x4 &matrix);
- QPlane3D transformed(const QMatrix4x4 &matrix) const;
-
- bool operator==(const QPlane3D &other);
- bool operator!=(const QPlane3D &other);
-
-private:
- QVector3D m_origin;
- QVector3D m_normal;
-};
-
-inline QPlane3D::QPlane3D() : m_normal(1.0f, 0.0f, 0.0f) {}
-
-inline QPlane3D::QPlane3D(const QVector3D &point, const QVector3D &normal)
- : m_origin(point), m_normal(normal)
-{
-}
-
-inline QPlane3D::QPlane3D(const QVector3D &p, const QVector3D &q, const QVector3D &r)
- : m_origin(p), m_normal(QVector3D::crossProduct(q - p, r - q))
-{
-}
-
-inline QVector3D QPlane3D::origin() const
-{
- return m_origin;
-}
-
-inline void QPlane3D::setOrigin(const QVector3D &value)
-{
- m_origin = value;
-}
-
-inline QVector3D QPlane3D::normal() const
-{
- return m_normal;
-}
-
-inline void QPlane3D::setNormal(const QVector3D& value)
-{
- m_normal = value;
-}
-
-inline void QPlane3D::transform(const QMatrix4x4 &matrix)
-{
- m_origin = matrix * m_origin;
- m_normal = matrix.mapVector(m_normal);
-}
-
-inline QPlane3D QPlane3D::transformed(const QMatrix4x4 &matrix) const
-{
- return QPlane3D(matrix * m_origin, matrix.mapVector(m_normal));
-}
-
-inline bool QPlane3D::operator==(const QPlane3D &other)
-{
- return m_origin == other.origin() && m_normal == other.normal();
-}
-
-inline bool QPlane3D::operator!=(const QPlane3D &other)
-{
- return m_origin != other.origin() || m_normal != other.normal();
-}
-
-inline bool qFuzzyCompare(const QPlane3D &plane1, const QPlane3D &plane2)
-{
- return qFuzzyCompare(plane1.origin(), plane2.origin()) &&
- qFuzzyCompare(plane1.normal(), plane2.normal());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QPlane3D &plane);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_QT3D_EXPORT QDataStream &operator<<(QDataStream &stream, const QPlane3D &plane);
-Q_QT3D_EXPORT QDataStream &operator>>(QDataStream &stream, QPlane3D &plane);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QPlane3D)
-
-QT_END_HEADER
-
-#endif // QPLANE3D_H
diff --git a/src/threed/math3d/qray3d.cpp b/src/threed/math3d/qray3d.cpp
deleted file mode 100644
index 9cdabd44..00000000
--- a/src/threed/math3d/qray3d.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qray3d.h"
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QRay3D
- \brief The QRay3D class defines a directional line in 3D space extending through an origin point.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::math
-
- A ray is defined by the origin() point and the direction() vector.
- Rays are infinite in length, extending out from origin() in
- both directions. If the direction() is zero length, then the
- behavior of the class is undefined.
-
- A ray can be thought of as a one-dimensional co-ordinate system.
- If the co-ordinate is \bold t then the origin() point is at
- \bold t = 0, the point origin() + direction() is at \bold t = 1,
- and the point origin() - direction() is at \bold t = -1.
- The point() method can be used to obtain the position of a point
- within this one-dimensional co-ordinate system. The fromPoint()
- method can be used to convert a point into a value in this
- one-dimensional co-ordinate system.
-*/
-
-/*!
- \fn QRay3D::QRay3D()
-
- Construct a default ray with an origin() of (0, 0, 0) and a
- direction() of (1, 0, 0).
-*/
-
-/*!
- \fn QRay3D::QRay3D(const QVector3D &origin, const QVector3D &direction)
-
- Construct a ray given its defining \a origin and \a direction. The
- \a direction does not need to be normalized.
-
- To construct a ray that passes through two points, use the following:
-
- \code
- QRay3D thruAB(pointA, pointB - pointA);
- \endcode
-*/
-
-/*!
- \fn QVector3D QRay3D::origin() const
-
- Returns the origin of this ray. The default value is (0, 0, 0).
-
- \sa setOrigin(), direction()
-*/
-
-/*!
- \fn void QRay3D::setOrigin(const QVector3D &value)
-
- Sets the origin point of this ray to \a value.
-
- \sa origin(), setDirection()
- */
-
-/*!
- \fn QVector3D QRay3D::direction() const
-
- Returns the direction vector of this ray. The default value is (1, 0, 0).
-
- \sa setDirection(), origin()
-*/
-
-/*!
- \fn void QRay3D::setDirection(const QVector3D &direction)
-
- Sets the direction vector of this ray to \a direction.
-
- \sa direction(), setOrigin()
-*/
-
-/*!
- Returns true if \a point lies on this ray; false otherwise.
-*/
-bool QRay3D::contains(const QVector3D &point) const
-{
- QVector3D ppVec(point - m_origin);
- if (ppVec.isNull()) // point coincides with origin
- return true;
- qreal dot = QVector3D::dotProduct(ppVec, m_direction);
- if (qFuzzyIsNull(float(dot)))
- return false;
- return qFuzzyCompare(dot*dot, ppVec.lengthSquared() * m_direction.lengthSquared());
-}
-
-/*!
- Returns true if \a ray lies on this ray; false otherwise. If true,
- this implies that the two rays are the actually the same, but with
- different origin() points or an inverted direction().
-*/
-bool QRay3D::contains(const QRay3D &ray) const
-{
- qreal dot = QVector3D::dotProduct(m_direction, ray.direction());
- if (!qFuzzyCompare(dot*dot, m_direction.lengthSquared() * ray.direction().lengthSquared()))
- return false;
- return contains(ray.origin());
-}
-
-/*!
- \fn QVector3D QRay3D::point(qreal t) const
-
- Returns the point on the ray defined by moving \a t units
- along the ray in the direction of the direction() vector.
- Note that \a t may be negative in which case the point returned
- will lie behind the origin() point with respect to the
- direction() vector.
-
- The units for \a t are defined by direction(). The return value
- is precisely origin() + t * direction().
-
- \sa fromPoint(), distanceTo()
-*/
-
-/*!
- Returns the number of direction() units along the ray from origin()
- to \a point. Essentially, this function computes the value t, where
- \a point = origin() + t * direction(). If \a point is not on the ray,
- then the closest point that is on the ray will be used instead.
-
- If the return value is positive, then \a point lies in front of
- the origin() with respect to the direction() vector. If the return
- value is negative, then \a point lies behind the origin() with
- respect to the direction() vector.
-
- \sa point(), project()
-*/
-qreal QRay3D::fromPoint(const QVector3D &point) const
-{
- return QVector3D::dotProduct(point - m_origin, m_direction) /
- m_direction.lengthSquared();
-}
-
-/*!
- Returns the projection of \a vector onto this ray. In the
- following diagram, the dotted line is the ray, and V is the
- \a vector. The return value will be the vector V':
-
- \image qray3d-project.png
-
- \sa fromPoint()
-*/
-QVector3D QRay3D::project(const QVector3D &vector) const
-{
- QVector3D norm = m_direction.normalized();
- return QVector3D::dotProduct(vector, norm) * norm;
-}
-
-/*!
- Returns the minimum distance from this ray to \a point, or equivalently
- the length of a line perpendicular to this ray which passes through
- \a point. If \a point is on the ray, then this function will return zero.
-
- \sa point()
-*/
-qreal QRay3D::distanceTo(const QVector3D &point) const
-{
- qreal t = fromPoint(point);
- return (point - (m_origin + t * m_direction)).length();
-}
-
-/*!
- \fn void QRay3D::transform(const QMatrix4x4 &matrix)
-
- Transforms this ray using \a matrix, replacing origin() and
- direction() with the transformed versions.
-
- \sa transformed()
-*/
-
-/*!
- \fn QRay3D QRay3D::transformed(const QMatrix4x4 &matrix) const
-
- Returns a new ray that is formed by transforming origin()
- and direction() using \a matrix.
-
- \sa transform()
-*/
-
-/*!
- \fn bool QRay3D::operator==(const QRay3D &other)
-
- Returns true if this ray is the same as \a other; false otherwise.
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QRay3D::operator!=(const QRay3D &other)
-
- Returns true if this ray is not the same as \a other; false otherwise.
-
- \sa operator==()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QRay3D &ray1, const QRay3D &ray2)
- \relates QRay3D
-
- Returns true if \a ray1 and \a ray2 are almost equal; false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QRay3D &ray)
-{
- dbg.nospace() << "QRay3D(origin("
- << ray.origin().x() << ", " << ray.origin().y() << ", "
- << ray.origin().z() << ") - direction("
- << ray.direction().x() << ", " << ray.direction().y() << ", "
- << ray.direction().z() << "))";
- return dbg.space();
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QRay3D &ray)
- \relates QRay3D
-
- Writes the given \a ray to the given \a stream and returns a
- reference to the stream.
-*/
-
-QDataStream &operator<<(QDataStream &stream, const QRay3D &ray)
-{
- stream << ray.origin();
- stream << ray.direction();
- return stream;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QRay3D &ray)
- \relates QRay3D
-
- Reads a 3D ray from the given \a stream into the given \a ray
- and returns a reference to the stream.
-*/
-
-QDataStream &operator>>(QDataStream &stream, QRay3D &ray)
-{
- QVector3D origin, direction;
- stream >> origin;
- stream >> direction;
- ray = QRay3D(origin, direction);
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/threed/math3d/qray3d.h b/src/threed/math3d/qray3d.h
deleted file mode 100644
index 74afe97e..00000000
--- a/src/threed/math3d/qray3d.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QRAY3D_H
-#define QRAY3D_H
-
-#include "qt3dglobal.h"
-#include <QtGui/qvector3d.h>
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QRay3D
-{
-public:
- QRay3D();
- QRay3D(const QVector3D &origin, const QVector3D &direction);
-
- QVector3D origin() const;
- void setOrigin(const QVector3D & value);
-
- QVector3D direction() const;
- void setDirection(const QVector3D & value);
-
- bool contains(const QVector3D &point) const;
- bool contains(const QRay3D &ray) const;
-
- QVector3D point(qreal t) const;
- qreal fromPoint(const QVector3D &point) const;
-
- QVector3D project(const QVector3D &vector) const;
-
- qreal distanceTo(const QVector3D &point) const;
-
- void transform(const QMatrix4x4 &matrix);
- QRay3D transformed(const QMatrix4x4 &matrix) const;
-
- bool operator==(const QRay3D &other);
- bool operator!=(const QRay3D &other);
-
-private:
- QVector3D m_origin;
- QVector3D m_direction;
-
-};
-
-inline QRay3D::QRay3D() : m_direction(1.0f, 0.0f, 0.0f) {}
-
-inline QRay3D::QRay3D(const QVector3D &origin, const QVector3D &direction)
- : m_origin(origin)
- , m_direction(direction)
-{
-}
-
-inline QVector3D QRay3D::origin() const
-{
- return m_origin;
-}
-
-inline void QRay3D::setOrigin(const QVector3D &value)
-{
- m_origin = value;
-}
-
-inline QVector3D QRay3D::direction() const
-{
- return m_direction;
-}
-
-inline void QRay3D::setDirection(const QVector3D & value)
-{
- m_direction = value;
-}
-
-inline QVector3D QRay3D::point(qreal t) const
-{
- return m_origin + t * m_direction;
-}
-
-inline void QRay3D::transform(const QMatrix4x4 &matrix)
-{
- m_origin = matrix * m_origin;
- m_direction = matrix.mapVector(m_direction);
-}
-
-inline QRay3D QRay3D::transformed(const QMatrix4x4 &matrix) const
-{
- return QRay3D(matrix * m_origin, matrix.mapVector(m_direction));
-}
-
-inline bool QRay3D::operator==(const QRay3D &other)
-{
- return m_origin == other.origin() && m_direction == other.direction();
-}
-
-inline bool QRay3D::operator!=(const QRay3D &other)
-{
- return m_origin != other.origin() || m_direction != other.direction();
-}
-
-inline bool qFuzzyCompare(const QRay3D &ray1, const QRay3D &ray2)
-{
- return qFuzzyCompare(ray1.origin(), ray2.origin()) &&
- qFuzzyCompare(ray1.direction(), ray2.direction());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QRay3D &ray);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_QT3D_EXPORT QDataStream &operator<<(QDataStream &stream, const QRay3D &ray);
-Q_QT3D_EXPORT QDataStream &operator>>(QDataStream &stream, QRay3D &ray);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QRay3D)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/math3d/qsphere3d.cpp b/src/threed/math3d/qsphere3d.cpp
deleted file mode 100644
index 81e6c16c..00000000
--- a/src/threed/math3d/qsphere3d.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qsphere3d.h"
-#include "qray3d.h"
-#include "qbox3d.h"
-#include "qplane3d.h"
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QSphere3D
- \brief The QSphere3D class represents a mathematical sphere in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::math
-
- QSphere3D can be used to represent the bounding regions of objects
- in a 3D scene so that they can be easily culled if they are out of view.
- It can also be used to assist with collision testing.
-
- \sa QBox3D
-*/
-
-/*!
- \fn QSphere3D::QSphere3D()
-
- Constructs a default sphere with a center() of (0, 0, 0)
- and radius() of 1.
-*/
-
-/*!
- \fn QSphere3D::QSphere3D(const QVector3D &center, qreal radius)
-
- Constructs a sphere with the specified \a center and \a radius.
-*/
-
-/*!
- \fn QVector3D QSphere3D::center() const
-
- Returns the center of this sphere.
-
- \sa setCenter(), radius()
-*/
-
-/*!
- \fn void QSphere3D::setCenter(const QVector3D &center)
-
- Sets the \a center of this sphere.
-
- \sa center(), setRadius()
-*/
-
-/*!
- \fn qreal QSphere3D::radius() const
-
- Returns the radius of this sphere.
-
- \sa setRadius(), center()
-*/
-
-/*!
- \fn void QSphere3D::setRadius(qreal radius)
-
- Sets the \a radius of this sphere.
-
- \sa radius(), setCenter()
-*/
-
-/*!
- \fn bool QSphere3D::contains(const QVector3D &point) const
-
- Returns true if \a point is contained within the bounds of
- this sphere; false otherwise.
-*/
-
-/*!
- Returns true if this sphere intersects \a ray; false otherwise.
-
- \sa intersection()
-*/
-bool QSphere3D::intersects(const QRay3D &ray) const
-{
- QVector3D centerToOrigin = ray.origin() - m_center;
- qreal term1 = ray.direction().lengthSquared();
- qreal term2 = 2.0f * QVector3D::dotProduct(centerToOrigin, ray.direction());
- qreal term3 = centerToOrigin.lengthSquared() - m_radius * m_radius;
- qreal det = term2 * term2 - (4.0f * term1 * term3);
- return term1 != 0.0f && det >= 0.0f;
-}
-
-/*!
- \fn bool QSphere3D::intersects(const QSphere3D &sphere) const
-
- Returns true if this sphere intersects \a sphere; false otherwise.
-
- \sa contains()
-*/
-
-/*!
- Returns true if this sphere intersects \a box; false otherwise.
-*/
-bool QSphere3D::intersects(const QBox3D &box) const
-{
- if (box.isFinite()) {
- // Use Arvo's Algorithm to determine if we have an intersection.
- qreal dist = 0.0f;
- qreal center = m_center.x();
- qreal minval = box.minimum().x();
- qreal maxval = box.maximum().x();
- if (center < minval)
- dist += (center - minval) * (center - minval);
- else if (center > maxval)
- dist += (center - maxval) * (center - maxval);
- center = m_center.y();
- minval = box.minimum().y();
- maxval = box.maximum().y();
- if (center < minval)
- dist += (center - minval) * (center - minval);
- else if (center > maxval)
- dist += (center - maxval) * (center - maxval);
- center = m_center.z();
- minval = box.minimum().z();
- maxval = box.maximum().z();
- if (center < minval)
- dist += (center - minval) * (center - minval);
- else if (center > maxval)
- dist += (center - maxval) * (center - maxval);
- return dist <= (m_radius * m_radius);
- } else {
- return box.isInfinite();
- }
-}
-
-/*!
- Returns true if this sphere intersects \a plane; false otherwise.
-*/
-bool QSphere3D::intersects(const QPlane3D &plane) const
-{
- return qAbs(plane.distanceTo(m_center)) <= m_radius;
-}
-
-/*!
- Finds the \a minimum_t and \a maximum_t values where \a ray intersects
- this sphere. Returns true if intersections were found; or false if there
- is no intersection.
-
- If \a minimum_t and \a maximum_t are set to the same value, then \a ray
- touches the surface of the sphere at a single point. If the t values are
- negative, then the intersection occurs before the ray's origin point
- in the reverse direction of the ray.
-
- The \a minimum_t and \a maximum_t values can be passed to QRay3D::point()
- to determine the actual intersection points, as shown in the following
- example:
-
- \code
- qreal minimum_t, maximum_t;
- if (sphere.intersection(ray, &minimum_t, &maximum_t)) {
- qDebug() << "intersections at"
- << ray.point(minimum_t) << "and"
- << ray.point(maximum_t);
- }
- \endcode
-
- \sa intersects(), QRay3D::point()
-*/
-bool QSphere3D::intersection(const QRay3D &ray, qreal *minimum_t, qreal *maximum_t) const
-{
- QVector3D centerToOrigin = ray.origin() - m_center;
- qreal term1 = ray.direction().lengthSquared();
- qreal term2 = 2.0f * QVector3D::dotProduct(centerToOrigin, ray.direction());
- qreal term3 = centerToOrigin.lengthSquared() - m_radius * m_radius;
- qreal det = term2 * term2 - (4.0f * term1 * term3);
- if (term1 == 0.0f || det < 0.0f) {
- *minimum_t = qSNaN();
- *maximum_t = qSNaN();
- return false;
- } else if (det == 0.0f) {
- *minimum_t = *maximum_t = -term2 / (2.0f * term1);
- } else {
- qreal sqrtDet = qSqrt(det);
- qreal t1 = (-term2 - sqrtDet) / (2.0f * term1);
- qreal t2 = (-term2 + sqrtDet) / (2.0f * term1);
- if (t1 < t2) {
- *minimum_t = t1;
- *maximum_t = t2;
- } else {
- *minimum_t = t2;
- *maximum_t = t1;
- }
- }
- return true;
-}
-
-/*!
- Returns the t value at which \a ray first intersects the surface of
- this sphere, or not-a-number if there is no intersection.
-
- When the \a ray intersects this sphere, the return value is a
- parametric value that can be passed to QRay3D::point() to determine
- the actual intersection point, as shown in the following example:
-
- \code
- qreal t = sphere.intersection(ray);
- QVector3D pt;
- if (qIsNaN(t)) {
- qWarning("no intersection occurred");
- else
- pt = ray.point(t);
- \endcode
-
- The \a ray might intersect at two points - as the ray passes through
- the sphere - one on the near side, one on the far side; where near and far
- are relative to the origin point of the ray. This function only
- returns the near intersection point.
-
- Only positive values on the ray are considered. This means that if
- the origin point of the ray is inside the sphere, there is only one
- solution, not two. To get the other solution, simply change
- the sign of the ray's direction vector. If the origin point of
- the ray is outside the sphere, and the direction points away from
- the sphere, then there will be no intersection.
-
- When the ray does not intersect the sphere in the positive direction,
- then the return value is not-a-number.
-
- \sa intersects(), QRay3D::point()
-*/
-qreal QSphere3D::intersection(const QRay3D &ray) const
-{
- qreal minimum_t, maximum_t;
- if (intersection(ray, &minimum_t, &maximum_t)) {
- if (minimum_t >= 0.0f)
- return minimum_t;
- else if (maximum_t >= 0.0f)
- return maximum_t;
- else
- return qSNaN();
- } else {
- return qSNaN();
- }
-}
-
-/*!
- \fn void QSphere3D::transform(const QMatrix4x4 &matrix)
-
- Transforms this sphere's center() and radius() according to \a matrix.
-
- It is assumed that \a matrix contains a uniform scale factor in the
- x, y, and z directions. Otherwise the radius() in the result is undefined.
-
- \sa transformed()
-*/
-
-/*!
- Returns the result of transforming this sphere's center() and radius()
- according to \a matrix.
-
- It is assumed that \a matrix contains a uniform scale factor in the
- x, y, and z directions. Otherwise the radius() in the result is undefined.
-
- \sa transform()
-*/
-QSphere3D QSphere3D::transformed(const QMatrix4x4 &matrix) const
-{
- return QSphere3D(matrix * m_center,
- matrix.mapVector(QVector3D(m_radius, 0, 0)).length());
-}
-
-/*!
- \fn bool QSphere3D::operator==(const QSphere3D &sphere) const
-
- Returns true if this sphere is the same as \a sphere; false otherwise.
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QSphere3D::operator!=(const QSphere3D &sphere) const
-
- Returns true if this sphere is not the same as \a sphere; false otherwise.
-
- \sa operator==()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QSphere3D &sphere1, const QSphere3D &sphere2)
- \relates QSphere3D
-
- Returns true if \a sphere1 and \a sphere2 are almost equal;
- false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QSphere3D &sphere)
-{
- dbg.nospace() << "QSphere3D(center=("
- << sphere.center().x() << ", " << sphere.center().y() << ", "
- << sphere.center().z() << "), radius=" << sphere.radius() << ')';
- return dbg.space();
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QSphere3D &sphere)
- \relates QSphere3D
-
- Writes the given \a sphere to the given \a stream and returns a
- reference to the stream.
-*/
-
-QDataStream &operator<<(QDataStream &stream, const QSphere3D &sphere)
-{
- stream << sphere.center();
- stream << double(sphere.radius());
- return stream;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QSphere3D &sphere)
- \relates QSphere3D
-
- Reads a 3D sphere from the given \a stream into the given \a sphere
- and returns a reference to the stream.
-*/
-
-QDataStream &operator>>(QDataStream &stream, QSphere3D &sphere)
-{
- QVector3D center;
- double radius;
- stream >> center;
- stream >> radius;
- sphere.setCenter(center);
- sphere.setRadius(qreal(radius));
- return stream;
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/math3d/qsphere3d.h b/src/threed/math3d/qsphere3d.h
deleted file mode 100644
index 9487a9b2..00000000
--- a/src/threed/math3d/qsphere3d.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QSPHERE3D_H
-#define QSPHERE3D_H
-
-#include "qt3dglobal.h"
-#include <QtGui/qvector3d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-class QRay3D;
-class QBox3D;
-class QPlane3D;
-
-class Q_QT3D_EXPORT QSphere3D
-{
-public:
- QSphere3D();
- QSphere3D(const QVector3D &center, qreal radius);
-
- QVector3D center() const;
- void setCenter(const QVector3D &center);
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- bool contains(const QVector3D &point) const;
-
- bool intersects(const QRay3D &ray) const;
- bool intersects(const QSphere3D &sphere) const;
- bool intersects(const QBox3D &box) const;
- bool intersects(const QPlane3D &plane) const;
-
- bool intersection(const QRay3D &ray, qreal *minimum_t, qreal *maximum_t) const;
- qreal intersection(const QRay3D &ray) const;
-
- void transform(const QMatrix4x4 &matrix);
- QSphere3D transformed(const QMatrix4x4 &matrix) const;
-
- bool operator==(const QSphere3D &sphere) const;
- bool operator!=(const QSphere3D &sphere) const;
-
-private:
- QVector3D m_center;
- qreal m_radius;
-};
-
-inline QSphere3D::QSphere3D() : m_radius(1.0f) {}
-
-inline QSphere3D::QSphere3D(const QVector3D &center, qreal radius)
- : m_center(center), m_radius(radius) {}
-
-inline QVector3D QSphere3D::center() const
-{
- return m_center;
-}
-
-inline void QSphere3D::setCenter(const QVector3D &center)
-{
- m_center = center;
-}
-
-inline qreal QSphere3D::radius() const
-{
- return m_radius;
-}
-
-inline void QSphere3D::setRadius(qreal radius)
-{
- m_radius = radius;
-}
-
-inline bool QSphere3D::contains(const QVector3D &point) const
-{
- return (point - m_center).lengthSquared() <= (m_radius * m_radius);
-}
-
-inline bool QSphere3D::intersects(const QSphere3D &sphere) const
-{
- qreal radsum = sphere.radius() + m_radius;
- return (sphere.center() - m_center).lengthSquared() <= (radsum * radsum);
-}
-
-inline void QSphere3D::transform(const QMatrix4x4 &matrix)
-{
- *this = transformed(matrix);
-}
-
-inline bool QSphere3D::operator==(const QSphere3D &sphere) const
-{
- return m_center == sphere.m_center && m_radius == sphere.m_radius;
-}
-
-inline bool QSphere3D::operator!=(const QSphere3D &sphere) const
-{
- return m_center != sphere.m_center || m_radius != sphere.m_radius;
-}
-
-inline bool qFuzzyCompare(const QSphere3D &sphere1, const QSphere3D &sphere2)
-{
- return qFuzzyCompare(sphere1.center(), sphere2.center()) &&
- qFuzzyCompare(sphere1.radius(), sphere2.radius());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QSphere3D &sphere);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_QT3D_EXPORT QDataStream &operator<<(QDataStream &stream, const QSphere3D &sphere);
-Q_QT3D_EXPORT QDataStream &operator>>(QDataStream &stream, QSphere3D &sphere);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QSphere3D)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/math3d/qtriangle3d.cpp b/src/threed/math3d/qtriangle3d.cpp
deleted file mode 100644
index ac1f0898..00000000
--- a/src/threed/math3d/qtriangle3d.cpp
+++ /dev/null
@@ -1,379 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qtriangle3d.h"
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QTriangle3D
- \brief The QTriangle3D class represents a triangle as three points in 3D space.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::math
-
- A triangle is defined by 3 points in 3D space. Since any 3 points define
- a plane, the triangle can be thought of as defining a plane, and forming a
- geometric region in that plane.
-
- If you need a simple plane, with no particular geometry, then
- QPlane3D is a more compact and mathematically sufficient class.
-
- The three points are labelled p(), q() and r() for consistency with
- textbook treatments. It is recommended that the points be supplied
- in counter-clockwise order for correct orientation of the
- triangle's plane().
-
- \sa QPlane3D
-*/
-
-/*!
- \fn QTriangle3D::QTriangle3D()
-
- Constructs a default triangle which lies in the x-z plane,
- with the three vertices (0, 0, 0), (1, 0, 0), and (0, 1, 0).
-*/
-
-/*!
- \fn QTriangle3D::QTriangle3D(const QVector3D &p, const QVector3D &q, const QVector3D &r)
-
- Constructs a triangle with the supplied \a p, \a q and \a r vertices.
-*/
-
-/*!
- \fn QVector3D QTriangle3D::p() const
-
- Returns the value of the P vertex on the triangle.
-
- \sa q(), r(), setP()
-*/
-
-/*!
- \fn void QTriangle3D::setP(const QVector3D &point)
-
- Sets the value of the P vertex on the triangle to \a point.
-
- \sa setQ(), setR(), p()
-*/
-
-/*!
- \fn QVector3D QTriangle3D::q() const
-
- Returns the value of the Q vertex on the triangle.
-
- \sa p(), r(), setQ()
-*/
-
-/*!
- \fn void QTriangle3D::setQ(const QVector3D &point)
-
- Sets the value of the Q vertex on the triangle \a point.
-
- \sa setP(), setR(), q()
-*/
-
-
-/*!
- \fn QVector3D QTriangle3D::r() const
-
- Returns the value of the R vertex on the triangle.
-
- \sa p(), q(), setR()
-*/
-
-/*!
- \fn void QTriangle3D::setR(const QVector3D &point)
-
- Sets the value of the R vertex on the triangle \a point.
-
- \sa setP(), setQ(), r()
-*/
-
-/*!
- \fn QPlane3D QTriangle3D::plane() const
-
- Returns the plane in which the triangle lies.
-
- \sa QPlane3D
-*/
-
-/*!
- \fn QVector3D QTriangle3D::center() const
-
- Returns the center of the triangle, which is the geometric average of the
- three vertices.
-*/
-
-/*!
- \fn QVector3D QTriangle3D::faceNormal() const
-
- Returns the vector normal to this triangle, computed from the
- cross-product of P-Q and Q-R. The result is not normalized.
-*/
-
-/*!
- Returns true if this triangle contains \a point; false otherwise.
- To contain the \a point means that:
- \list
- \o the point lies on the same plane as the triangle, and
- \o the point
- \list
- \o lies either wholly within the triangle, or
- \o lies on one of the sides, or
- \o coincides with one of the 3 vertices
- \endlist
- \endlist
-
- \sa intersects()
-*/
-bool QTriangle3D::contains(const QVector3D &point) const
-{
- // Check if the point is on the triangle's plane first.
- QVector3D normal = QVector3D::crossProduct(m_q - m_p, m_r - m_q);
- if (!qFuzzyIsNull(float(QVector3D::dotProduct(normal, m_p - point))))
- return false;
-
- // Compute the barycentric co-ordinates and use them to determine
- // if the point is within the triangle.
- QVector2D c = uv(point);
- if (c.x() < 0.0f || c.x() > 1.0f)
- return false;
- if (c.y() < 0.0f || c.y() > 1.0f)
- return false;
- if ((c.x() + c.y()) > 1.0f)
- return false;
- return true;
-}
-
-/*!
- Returns true if the \a ray intersects this triangle; false otherwise.
-
- This function will return false if the triangle is degenerate.
-
- \sa contains(), intersection()
-*/
-bool QTriangle3D::intersects(const QRay3D &ray) const
-{
- qreal t = plane().intersection(ray);
- if (qIsNaN(t))
- return false;
- return contains(ray.point(t));
-}
-
-/*!
- Returns the t value at which \a ray intersects this triangle, or
- not-a-number if there is no intersection.
-
- When the \a ray intersects this triangle, the return value is a
- parametric value that can be passed to QRay3D::point() to determine
- the actual intersection point, as shown in the following example:
-
- \code
- qreal t = triangle.intersection(ray);
- QVector3D pt;
- if (qIsNaN(t)) {
- qWarning("no intersection occurred");
- else
- pt = ray.point(t);
- \endcode
-
- \sa intersects(), contains(), QRay3D::point()
- */
-qreal QTriangle3D::intersection(const QRay3D &ray) const
-{
- qreal t = plane().intersection(ray);
- if (qIsNaN(t) || contains(ray.point(t)))
- return t;
- return qSNaN();
-}
-
-/*!
- Transforms the points of this triangle according to \a matrix.
-
- \sa transformed()
-*/
-void QTriangle3D::transform(const QMatrix4x4 &matrix)
-{
- m_p = matrix * m_p;
- m_q = matrix * m_q;
- m_r = matrix * m_r;
-}
-
-/*!
- Returns a new triangle that results from transforming this
- one using \a matrix.
-
- \sa transform()
-*/
-QTriangle3D QTriangle3D::transformed(const QMatrix4x4 &matrix) const
-{
- return QTriangle3D(matrix * m_p, matrix * m_q, matrix * m_r);
-}
-
-/*!
- Returns the (u, v) barycentric co-ordinates of \a point within
- this triangle.
-
- The returned barycentric co-ordinates will be (1, 0) at p(),
- (0, 1) at q(), and (0, 0) at r(). Technically, barycentric
- co-ordinates have three components with the corners at
- (1, 0, 0), (0, 1, 0), and (0, 0, 1). However, the third
- component is always equal to (1 - u - v) so we do not return it.
-
- The typical use case for this function is to convert an intersection
- point on a triangle into the texture co-ordinate corresponding to
- that point. If \c p, \c q, and \c r are the points on the triangle,
- with corresponding texture co-ordinates \c tp, \c tq, and \c tr,
- then the texture co-ordinate \c tc of \a point can be determined
- by the following code:
-
- \code
- QTriangle3D triangle(p, q, r);
- QVector2D uv = triangle.uv(point);
- QVector2D tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr;
- \endcode
-
- \sa contains(), intersection()
-*/
-QVector2D QTriangle3D::uv(const QVector3D &point) const
-{
- // Algorithm from: http://www.blackpawn.com/texts/pointinpoly/default.html
- // More: http://en.wikipedia.org/wiki/Barycentric_coordinates_(mathematics)
- QVector3D rq = m_q - m_r;
- QVector3D rp = m_p - m_r;
- QVector3D pp = point - m_r;
- qreal dot_rq_rq = QVector3D::dotProduct(rq, rq);
- qreal dot_rq_rp = QVector3D::dotProduct(rq, rp);
- qreal dot_rq_pp = QVector3D::dotProduct(rq, pp);
- qreal dot_rp_rp = QVector3D::dotProduct(rp, rp);
- qreal dot_rp_pp = QVector3D::dotProduct(rp, pp);
- qreal det = dot_rq_rq * dot_rp_rp - dot_rq_rp * dot_rq_rp;
- if (qFuzzyIsNull(float(det))) {
- // The point is probably not in the triangle, or the triangle
- // is degenerate. Return an out of range value for (u, v) so
- // that contains() will fail when this case happens.
- return QVector2D(-1.0f, -1.0f);
- }
- return QVector2D((dot_rq_rq * dot_rp_pp - dot_rq_rp * dot_rq_pp) / det,
- (dot_rp_rp * dot_rq_pp - dot_rq_rp * dot_rp_pp) / det);
-}
-
-/*!
- \fn bool QTriangle3D::operator==(const QTriangle3D &other)
-
- Returns true if this triangle is the same as \a other; false otherwise.
-
- \sa operator!=()
-*/
-
-/*!
- \fn bool QTriangle3D::operator!=(const QTriangle3D &other)
-
- Returns true if this triangle is not the same as \a other; false otherwise.
-
- \sa operator==()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QTriangle3D &triangle1, const QTriangle3D &triangle2)
- \relates QTriangle3D
-
- Returns true if \a triangle1 and \a triangle2 are almost equal;
- false otherwise.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QTriangle3D &triangle)
-{
- dbg.nospace() << "QTriangle3D(("
- << triangle.p().x() << ", " << triangle.p().y() << ", "
- << triangle.p().z() << "), ("
- << triangle.q().x() << ", " << triangle.q().y() << ", "
- << triangle.q().z() << "), ("
- << triangle.r().x() << ", " << triangle.r().y() << ", "
- << triangle.r().z() << "))";
- return dbg.space();
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QTriangle3D &triangle)
- \relates QTriangle3D
-
- Writes the given \a triangle to the given \a stream and returns a
- reference to the stream.
-*/
-
-QDataStream &operator<<(QDataStream &stream, const QTriangle3D &triangle)
-{
- stream << triangle.p();
- stream << triangle.q();
- stream << triangle.r();
- return stream;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QTriangle3D &triangle)
- \relates QTriangle3D
-
- Reads a 3D triangle from the given \a stream into the given \a triangle
- and returns a reference to the stream.
-*/
-
-QDataStream &operator>>(QDataStream &stream, QTriangle3D &triangle)
-{
- QVector3D p, q, r;
- stream >> p;
- stream >> q;
- stream >> r;
- triangle = QTriangle3D(p, q, r);
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/threed/math3d/qtriangle3d.h b/src/threed/math3d/qtriangle3d.h
deleted file mode 100644
index 8edb5512..00000000
--- a/src/threed/math3d/qtriangle3d.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QTRIANGLE3D_H
-#define QTRIANGLE3D_H
-
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector2d.h>
-#include "qray3d.h"
-#include "qplane3d.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QTriangle3D
-{
-public:
- QTriangle3D();
- QTriangle3D(const QVector3D &p, const QVector3D &q, const QVector3D &r);
-
- QVector3D p() const;
- void setP(const QVector3D & point);
-
- QVector3D q() const;
- void setQ(const QVector3D & point);
-
- QVector3D r() const;
- void setR(const QVector3D & point);
-
- QPlane3D plane() const;
- QVector3D center() const;
- QVector3D faceNormal() const;
-
- bool contains(const QVector3D &point) const;
-
- bool intersects(const QRay3D &ray) const;
- qreal intersection(const QRay3D &ray) const;
-
- void transform(const QMatrix4x4 &matrix);
- QTriangle3D transformed(const QMatrix4x4 &matrix) const;
-
- QVector2D uv(const QVector3D &point) const;
-
- bool operator==(const QTriangle3D &other);
- bool operator!=(const QTriangle3D &other);
-
-private:
- QVector3D m_p, m_q, m_r;
-};
-
-inline QTriangle3D::QTriangle3D()
- : m_p(0.0f, 0.0f, 0.0f)
- , m_q(1.0f, 0.0f, 0.0f)
- , m_r(0.0f, 1.0f, 0.0f) {}
-
-inline QTriangle3D::QTriangle3D(const QVector3D &p, const QVector3D &q, const QVector3D &r)
- : m_p(p)
- , m_q(q)
- , m_r(r) {}
-
-inline QVector3D QTriangle3D::p() const
-{
- return m_p;
-}
-
-inline void QTriangle3D::setP(const QVector3D &point)
-{
- m_p = point;
-}
-
-inline QVector3D QTriangle3D::q() const
-{
- return m_q;
-}
-
-inline void QTriangle3D::setQ(const QVector3D &point)
-{
- m_q = point;
-}
-
-inline QVector3D QTriangle3D::r() const
-{
- return m_r;
-}
-
-inline void QTriangle3D::setR(const QVector3D &point)
-{
- m_r = point;
-}
-
-inline QPlane3D QTriangle3D::plane() const
-{
- return QPlane3D(m_p, m_q, m_r);
-}
-
-inline QVector3D QTriangle3D::center() const
-{
- return (m_p + m_q + m_r) / 3.0f;
-}
-
-inline QVector3D QTriangle3D::faceNormal() const
-{
- return QVector3D::crossProduct(m_q - m_p, m_r - m_q);
-}
-
-inline bool QTriangle3D::operator==(const QTriangle3D &other)
-{
- return m_p == other.m_p && m_q == other.m_q && m_r == other.m_r;
-}
-
-inline bool QTriangle3D::operator!=(const QTriangle3D &other)
-{
- return m_p != other.m_p || m_q != other.m_q || m_r != other.m_r;
-}
-
-inline bool qFuzzyCompare
- (const QTriangle3D &triangle1, const QTriangle3D &triangle2)
-{
- return qFuzzyCompare(triangle1.p(), triangle2.p()) &&
- qFuzzyCompare(triangle1.q(), triangle2.q()) &&
- qFuzzyCompare(triangle1.r(), triangle2.r());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QTriangle3D &triangle);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_QT3D_EXPORT QDataStream &operator<<(QDataStream &stream, const QTriangle3D &triangle);
-Q_QT3D_EXPORT QDataStream &operator>>(QDataStream &stream, QTriangle3D &triangle);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QTriangle3D)
-
-QT_END_HEADER
-
-#endif // QTRIANGLE3D_H
diff --git a/src/threed/network/network.pri b/src/threed/network/network.pri
deleted file mode 100644
index 1aafa9db..00000000
--- a/src/threed/network/network.pri
+++ /dev/null
@@ -1,12 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += \
- network/qdownloadmanager.h \
- network/qabstractdownloadmanager.h \
- network/qthreadeddownloadmanager.h
-SOURCES += \
- qdownloadmanager.cpp \
- network/qthreadeddownloadmanager.cpp \
- network/qabstractdownloadmanager.cpp
-PRIVATE_HEADERS += \
- network/qthreadeddownloadmanager_p.h
diff --git a/src/threed/network/qabstractdownloadmanager.cpp b/src/threed/network/qabstractdownloadmanager.cpp
deleted file mode 100644
index a7f21380..00000000
--- a/src/threed/network/qabstractdownloadmanager.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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$
-**
-****************************************************************************/
-
-/*!
- \class QAbstractDownloadManager
- \brief The QAbstractDownloadManager class provides a base class for asset data download capability.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::network
-
- QDownloadManager encapsulates the functions needed for the downloading
- of asset data (eg. textures) from a network URL (eg. a website).
-
- The QAbstractDownloadManager provides only the framework for this, and
- should be extended/overidden by the user to provide a specific implementation.
-
- There are two extant implementations using this base class: QDownloadManager, which
- provides for asynchronous data transfer from a single thread, and QThreadedDownloadManager,
- which spawns its own download thread.
-*/
-
-/*!
- \fn QAbstractDownloadManager::QAbstractDownloadManager(QObject *parent)
- Constructs a new instance of the QDownloadManager and attach it
- to a \a parent QObject.
-*/
-
-/*!
- \fn QAbstractDownloadManager::beginDownload(QUrl url)
- Instructs the QDownloadManager to download the content specified
- in \a url. This may be a texture, 3d model, or similar.
-
- A return value of true indicates that the network request was
- successfully queued for sending, while a return value of false
- indicates a problem with sending (possibly a poorly specified URL, or
- network failure).
-*/
-
-/*!
- \fn QAbstractDownloadManager::downloadComplete(QByteArray assetData)
- \internal
- This signal is emitted when the network request has been completed.
-
- The \a assetData transmitted by the signal contains the content which
- has been downloaded as a QByteArray.
-
- If this value is NULL then the download has failed.
-*/
diff --git a/src/threed/network/qabstractdownloadmanager.h b/src/threed/network/qabstractdownloadmanager.h
deleted file mode 100644
index 18940529..00000000
--- a/src/threed/network/qabstractdownloadmanager.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QABSTRACTDOWNLOADMANAGER_H
-#define QABSTRACTDOWNLOADMANAGER_H
-
-#include "qglnamespace.h"
-#include <QObject>
-#include <QUrl>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QAbstractDownloadManager : public QObject
-{
- Q_OBJECT
-public:
- explicit QAbstractDownloadManager(QObject *parent = 0):QObject(parent){}
-
- virtual bool beginDownload(QUrl url) = 0;
-
-signals:
- void downloadComplete(QByteArray assetData);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTDOWNLOADMANAGER_H
diff --git a/src/threed/network/qdownloadmanager.cpp b/src/threed/network/qdownloadmanager.cpp
deleted file mode 100644
index edc49fce..00000000
--- a/src/threed/network/qdownloadmanager.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qdownloadmanager.h"
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDownloadManager
- \brief The QDownloadManager class provides asset data download capability within the
- current thread.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::network
-
- QDownloadManager extends the QAbstractDownloadManager class for use in a
- single-threaded Qt3D application. The QDownloadManager performs its network
- activities asynchronously, and processing will continue as normal while the download
- is underway (ie. the call is non-blocking).
-
- It should be noted that this does not preclude its usage in a multi-threaded
- application, rather that it does not itself spawn any threads of its own.
-
- In circumstances where an application will benefit greatly from multithreading,
- the developer may prefer to use the QThreadedDownloadManager.
-
- At the core of QDownloadManager is a QNetworkAccessManager which is
- shared by all instances of QDownloadManager. The download manager itself
- provides all handling of network requests and replies internally, and
- allows for redirection of URLs and handling of errors without the need
- for the user to query network replies.
-
- To use the QDownloadManager simply create an instance of the class
- within your code, and connect QDownloadManager's downloadComplete() signal
- to a slot in your own code, then call the downloadAsset() function.
-
- For example
-
- \code
- QDownloadManager dlmanage;
-
- connect(this, SLOT(myReceiverSlot(QByteArray)), &dlmanage, SIGNAL(downloadComplete(QByteArray)));
-
- if (!dlmanage.downloadAsset(QUrl("www.my.image.url.net/image.jpg"))) {
- dWarning("the manager was unable to send the url request.");
- }
- \endcode
-
- The QDownloadManager will emit the downloadComplete() signal which contains
- all of the downloaded data in a QByteArray. It is the user's responsibility
- to convert this data to the format they require, and to verify that it is
- correct.
-*/
-
-Q_GLOBAL_STATIC(QNetworkAccessManager, getNetworkAccessManager)
-
-/*!
- Constructs a new instance of the QDownloadManager and attach it
- to a \a parent QObject. Internally this initialises the
- QNetworkAccessManager instance which is shared by all instances of
- this class, and manages downloading of asset data.
-*/
-QDownloadManager::QDownloadManager(QObject *parent) : QAbstractDownloadManager(parent)
-{
-}
-
-
-/*!
- Destroys the current instance of the QDownloadManager. The destructor
- checks whether other instances of the class exist, and if none are found
- it deletes the internal QNetworkAccessManager instance.
-*/
-QDownloadManager::~QDownloadManager()
-{
-}
-
-/*!
- Instructs the QDownloadManager to download the content specified
- in \a assetUrl. This may be a texture, 3d model, or similar.
-
- A return value of true indicates that the network request was
- successfully queued for sending, while a return value of false
- indicates a problem with sending (possibly a poorly specified URL, or
- network failure).
-*/
-bool QDownloadManager::beginDownload(QUrl assetUrl)
-{
- //URL Sanity check
- if ( ! assetUrl.isValid()) {
- qWarning() << "Invalid texture URL: " << assetUrl.toString();
- return false;
- }
-
- QNetworkRequest request(assetUrl);
- request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- QNetworkReply *netReply = getNetworkAccessManager()->get(request);
-
- if (!netReply) {
- qWarning() << "Unable to send the request to the network.";
- return false;
- }
-
- connect(netReply, SIGNAL(finished()), this, SLOT(netReplyDone()));
- return true;
-}
-
-/*!
- \internal
- Internally used slot which is invoked when a download is finished.
- This handles redirection of URLs internally, as well as error checking.
-
- A successful download will emit the downloadComplete() signal which
- the user is responsible for handling in their own application.
-
- \sa downloadComplete()
-*/
-void QDownloadManager::netReplyDone()
-{
- //Ensure sanity of the sender
- QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
-
- if (!reply) {
- qWarning("DownloadManager's signal sender was not a QNetworkReply.");
- return;
- }
-
- if (reply->error() != QNetworkReply::NoError) {
- qWarning() << "Error in network reply: " << reply->url() << "(" << reply->errorString() << ")";
- reply->deleteLater();
- QByteArray tempArray;
- tempArray.clear();
- emit downloadComplete(tempArray);
- return;
- }
-
- //In the case of a reply which is a redirect
- QVariant redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirection.isValid()) {
- QUrl url = redirection.toUrl();
- //Check if we have a relative URL
- if (url.isRelative()) {
- url.setScheme(reply->url().scheme());
- url.setEncodedHost(reply->url().encodedHost());
- }
-
- //Reissue redirected request.
- QNetworkRequest request(url);
- if (getNetworkAccessManager())
- {
- QNetworkReply * netReply = getNetworkAccessManager()->get(request);
- connect(netReply, SIGNAL(finished()), SLOT(netReplyDone()));
- reply->deleteLater();
- } else {
- QByteArray tempArray;
- tempArray.clear();
- emit downloadComplete(tempArray);
- }
-
- return;
- }
-
- //In the case of just data being returned
- //qDebug() << "ContentType:" << reply->header(QNetworkRequest::ContentTypeHeader).toString();
- QByteArray assetData;
- assetData = reply->readAll();
- reply->deleteLater();
-
- emit downloadComplete(assetData);
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/network/qdownloadmanager.h b/src/threed/network/qdownloadmanager.h
deleted file mode 100644
index 202726c1..00000000
--- a/src/threed/network/qdownloadmanager.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 DOWNLOADMANAGER_H
-#define DOWNLOADMANAGER_H
-
-#include "qabstractdownloadmanager.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QNetworkAccessManager;
-class QUrl;
-
-class Q_QT3D_EXPORT QDownloadManager : public QAbstractDownloadManager {
- Q_OBJECT
-public:
- explicit QDownloadManager(QObject *parent = 0);
-
- ~QDownloadManager();
-
- bool beginDownload(QUrl assetUrl);
-public slots:
- void netReplyDone();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // DOWNLOADMANAGER_H
diff --git a/src/threed/network/qthreadeddownloadmanager.cpp b/src/threed/network/qthreadeddownloadmanager.cpp
deleted file mode 100644
index 61c2e561..00000000
--- a/src/threed/network/qthreadeddownloadmanager.cpp
+++ /dev/null
@@ -1,386 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qthreadeddownloadmanager.h"
-#include "qthreadeddownloadmanager_p.h"
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QDebug>
-#include <QEventLoop>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QThreadedDownloadManager
- \brief The QThreadedDownloadManager class provides asset data download capability which
- runs in its own download thread.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::network
-
- QThreadedDownloadManager extends the QAbstractDownloadManager class for use in a
- multi-threaded Qt3D application. The QThreadedDownloadManager creates a single download
- thread which is shared by all instances of the class. This thread is based on QThread,
- and it automatically queues and dispatches network requests.
-
- The downloader thread contains its own a QNetworkAccessManager. The download manager
- itself provides all handling of network requests and replies internally, and
- allows for redirection of URLs and handling of errors without the need
- for the user to query network replies.
-
- To use the QAbstractDownloadManager simply create an instance of the class
- within your code, and connect QDownloadManager's downloadComplete() signal
- to a slot in your own code, then call the downloadAsset() function.
-
- For example
-
- \code
- QAbstractDownloadManager dlmanage;
-
- connect(this, SLOT(myReceiverSlot(QByteArray)), &dlmanage, SIGNAL(downloadComplete(QByteArray)));
-
- if (!dlmanage.downloadAsset(QUrl("www.my.image.url.net/image.jpg"))) {
- dWarning("the manager was unable to send the url request.");
- }
- \endcode
-
- The QAbstractDownloadManager will emit the downloadComplete() signal which contains
- all of the downloaded data in a QByteArray. It is the user's responsibility
- to convert this data to the format they require, and to verify that it is
- correct.
-
- When no requests are queue, the QAbstractDownloadManager will halt the downloader
- thread. Multiple QAbstractDownloadManager classes can simultaneously submit
- requests, though the classes themselves are not intended to be completely thread
- safe, and developers should refrain from attempting to interact with the
- underlying classes through anything other than the specified API.
-*/
-
-Q_GLOBAL_STATIC(QDownloadThread, getDownloadThread)
-
-/*!
- Constructs a new instance of the QDownloadManager and attach it
- to a \a parent QObject.
-*/
-QThreadedDownloadManager::QThreadedDownloadManager(QObject *parent) :
- QAbstractDownloadManager(parent)
-{
-}
-
-/*!
- Destroys the current instance of the QThreadedDownloadManager. The destructor
- checks whether other instances of the class exist, and if none are found
- it sends a signal to the download thread to halt. It waits for the thread
- to end, then deletes the thread instance.
-*/
-QThreadedDownloadManager::~QThreadedDownloadManager()
-{
-}
-
-/*!
- Instructs the QThreadedDownloadManager to start the download thread. If no thread
- class currently exists this function will create one.
-
- If an existing thread is already in the process of shutting down the function will wait
- for the thread to end before re-starting it.
-
- If an existing thread is running, the function will do nothing.
-*/
-void QThreadedDownloadManager::beginThread()
-{
- //Connect the thread instance if one doesn't exist
- connect(this, SIGNAL(endThread()), getDownloadThread(), SLOT(quit()));
-
- //Signal thread completion so we can do any cleanup
- connect(getDownloadThread(), SIGNAL(finished()), this, SLOT(threadExit()));
-
- //If thread has had a quit message posted, wait until it's done before commencing
- if (getDownloadThread()->isThreadQuitting())
- {
- if (!getDownloadThread()->wait(1000))
- {
- qWarning("Download thread did not finish in timely manner - killing");
- getDownloadThread()->terminate();
- qWarning("Waiting for termination");
- while (getDownloadThread()->wait(1000)) {}
- }
- }
-
- //Spin the thread if it isn't running, otherwise, it's already going, so just carry on.
- if (!getDownloadThread()->isRunning()) {
- getDownloadThread()->start();
- }
-}
-
-/*!
- Instructs the QThreadedDownloadManager to download the content specified
- in \a assetUrl. This may be a texture, 3d model, or similar.
-
- A return value of true indicates that the network request was
- successfully queued for sending, while a return value of false
- indicates a problem with sending (possibly a poorly specified URL, or
- network failure).
-*/
-bool QThreadedDownloadManager::beginDownload(QUrl assetUrl)
-{
- //Ensure a thread is running
- beginThread();
-
- //Create the download instance - this object will be transferred to worker thread
- //control once all signals and slots to the current thread have been connected.
- QDownloadInstance * cObject = new QDownloadInstance();
-
- cObject->doSetup(*this);
- cObject->moveToThread(getDownloadThread());
-
- emit startDownload(assetUrl);
- return true;
-}
-
-/*!
- Instructs the QThreadedDownloadManager that the network replies have been received
- successfully. This currently performs no other processing, though is retained
- and can be overriden for debugging purposes.
-*/
-void QThreadedDownloadManager::netReplyDone()
-{
- //do nothing - this is kept for debugging/extension purposes
-}
-
-/*!
- Instructs the QThreadedDownloadManager that the downloader thread has exited
- successfully. This currently performs no other processing, though is retained
- and can be overriden for debugging purposes.
-*/
-void QThreadedDownloadManager::threadExit()
-{
- //do nothing - this is kept for debugging/extension purposes
-}
-
-/*!
- \fn QThreadedDownloadManager::endThread()
- Signals the download thread to exit. This will be performed gracefully, and
- remaining messages in the message loop will be processed.
-*/
-
-/*!
- \fn QThreadedDownloadManager::startDownload(QUrl assetUrl)
- Signals the download thread to begin downloading from \a assetUrl. This will
- be performed in the background until the download is complete.
-*/
-
-//Private Function Implementation for QDownloadInstance below.
-QDownloadInstance::QDownloadInstance(QObject *parent) : QObject(parent)
-{
- //do nothing
-}
-
-QDownloadInstance::~QDownloadInstance()
-{
- //do nothing
-}
-
-void QDownloadInstance::doSetup(QThreadedDownloadManager &cComm)
-{
- //Connect messages for starting the thread and alerting for completion of downloading (or error states)
- connect (&cComm, SIGNAL(startDownload(QUrl)), this, SLOT(doWork(QUrl)));
- connect (this, SIGNAL(downloadComplete(QByteArray)), &cComm, SIGNAL(downloadComplete(QByteArray)));
-}
-
-void QDownloadInstance::doWork(QUrl assetUrl)
-{
- //Get the network access manager belonging to the QDownloadThread we're in (if any)
- QNetworkAccessManager * netAccessMgr;
- if (!(netAccessMgr=getNetworkManager())) {
- emit downloadComplete(NULL);
- return;
- }
-
- //Send requests as needed.
- QNetworkRequest request(assetUrl);
- request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- QNetworkReply *netReply = netAccessMgr->get(request);
-
- connect(netReply, SIGNAL(finished()), this, SLOT(doneWork()));
- connect (this, SIGNAL(killDownloadThread()), getDownloadThread(), SLOT(quit()));
-
- //Add one to the current request count
- incrementRequestCount();
-}
-
-void QDownloadInstance::doneWork()
-{
- //Ensure sanity of the sender as a QNetworkReply
- QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
- if (!reply) {
- qWarning("QDownload::DoneWork signal sender was not a QNetworkReply.");
- sender()->deleteLater();
- return;
- }
-
- //Check for error states
- if (reply->error() != QNetworkReply::NoError) {
- qWarning() << "Error in network reply: " << reply->url() << "(" << reply->errorString() << ")";
- reply->deleteLater();
- emit downloadComplete(NULL);
- sender()->deleteLater();
- deleteLater();
- decrementRequestCount();
- return;
- }
-
- //In the case of a reply which is a redirect
- QVariant redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirection.isValid()) {
- QUrl url = redirection.toUrl();
- //Check if we have a relative URL
- if (url.isRelative()) {
- url.setScheme(reply->url().scheme());
- url.setEncodedHost(reply->url().encodedHost());
- }
-
- //Reissue redirected request.
- QNetworkRequest request(url);
- QNetworkAccessManager * netAccessMgr;
- if (!(netAccessMgr=getNetworkManager())) {
- emit downloadComplete(NULL);
- return;
- }
- QNetworkReply * netReply = netAccessMgr->get(request);
- connect(netReply, SIGNAL(finished()), SLOT(netReplyDone()));
- reply->deleteLater();
- return;
- }
-
- //In the case of just data being returned
- //qDebug() << "ContentType:" << reply->header(QNetworkRequest::ContentTypeHeader).toString();
- QByteArray assetData;
- assetData = reply->readAll();
- emit downloadComplete(assetData);
- reply->deleteLater();
-
- //A successful request means that we can decrement the number of requests in the current
- //thread - once this reaches zero, the thread will be halted for efficiency.
- deleteLater();
- decrementRequestCount();
-}
-
-QNetworkAccessManager * QDownloadInstance::getNetworkManager()
-{
- QDownloadThread *downloadThread = qobject_cast<QDownloadThread*>(thread());
-
- if (!downloadThread)
- {
- qWarning() << "QDownload instance is not running in a DownloadThread - cannot access network.";
- return NULL;
- }
-
- return downloadThread->m_netAccessMgr;
-}
-
-void QDownloadInstance::incrementRequestCount()
-{
- QDownloadThread *downloadThread = qobject_cast<QDownloadThread*>(thread());
-
- if (!downloadThread)
- {
- qWarning() << "QDownload instance is not running in a DownloadThread - cannot increment network request count.";
- return;
- }
-
- //We keep a count of the number of network requests currently queued by the
- //network access manager in the thread. This is used to check if we want to keep the
- //thread running - if no requests are pending we will simply kill the thread.
- downloadThread->m_requestCount++;
-}
-
-void QDownloadInstance::decrementRequestCount()
-{
- QDownloadThread *downloadThread = qobject_cast<QDownloadThread*>(thread());
-
- if (!downloadThread)
- {
- qWarning() << "QDownload instance is not running in a DownloadThread - cannot decrement network request count.";
- return;
- }
-
- //We keep a count of the number of network requests currently queued by the
- //network access manager in the thread. This is used to check if we want to keep the
- //thread running - if no requests are pending we will simply kill the thread (after
- //processing current messages, of course).
- downloadThread->m_requestCount--;
-
- if (downloadThread->m_requestCount<=0) {
- downloadThread->m_threadQuitting = true;
- emit killDownloadThread();
- }
-}
-
-//Private Function Implementation for QDownloadThread below.
-QDownloadThread::QDownloadThread(QObject *parent) : QThread(parent)
-{
- m_threadQuitting = false;
- m_requestCount = 0;
- m_netAccessMgr = 0;
-}
-
-QDownloadThread::~QDownloadThread()
-{
-}
-
-void QDownloadThread::run()
-{
- //When we run the thread we ensure a valid QNetworkAccessManager exists.
- if (!m_netAccessMgr) {
- m_netAccessMgr = new QNetworkAccessManager(this);
- }
-
- m_threadQuitting = false;
- exec();
-}
-
-bool QDownloadThread::isThreadQuitting() const
-{
- return m_threadQuitting;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/network/qthreadeddownloadmanager.h b/src/threed/network/qthreadeddownloadmanager.h
deleted file mode 100644
index 08a9fb3a..00000000
--- a/src/threed/network/qthreadeddownloadmanager.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QTHREADEDDOWNLOADMANAGER_H
-#define QTHREADEDDOWNLOADMANAGER_H
-
-#include "qabstractdownloadmanager.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-#define QT3D_MULTITHREAD "QT3D_MULTITHREAD"
-
-QT_MODULE(Qt3D)
-
-class QDownloadThread;
-
-class Q_QT3D_EXPORT QThreadedDownloadManager : public QAbstractDownloadManager
-{
- Q_OBJECT
-public:
- explicit QThreadedDownloadManager(QObject *parent = 0);
- ~QThreadedDownloadManager();
-
- void beginThread();
- bool beginDownload(QUrl assetUrl);
-signals:
- void endThread();
- void startDownload(QUrl assetUrl);
-public slots:
- void netReplyDone();
- void threadExit();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTHREADEDDOWNLOADMANAGER_H
diff --git a/src/threed/network/qthreadeddownloadmanager_p.h b/src/threed/network/qthreadeddownloadmanager_p.h
deleted file mode 100644
index 2cf2360e..00000000
--- a/src/threed/network/qthreadeddownloadmanager_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QTHREADEDDOWNLOADMANAGER_P_H
-#define QTHREADEDDOWNLOADMANAGER_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.
-//
-
-#include "qthreadeddownloadmanager.h"
-#include <QThread>
-#include <QMutex>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QNetworkAccessManager;
-
-//This is the main download thread where the network requests are queued and
-//processed.
-class QDownloadThread : public QThread
-{
- Q_OBJECT
- friend class QDownloadInstance;
-public:
- QDownloadThread(QObject *parent = 0);
- ~QDownloadThread();
-
- void run();
-
- bool isThreadQuitting() const;
-protected:
- QNetworkAccessManager * m_netAccessMgr;
- int m_requestCount;
- bool m_threadQuitting;
-};
-
-//This is a single instance of a download request, and acts as an intermediary
-//processing object between threads.
-class QDownloadInstance : public QObject
-{
- Q_OBJECT
-public:
- explicit QDownloadInstance(QObject *parent = 0);
- ~QDownloadInstance();
- void doSetup(QThreadedDownloadManager &cComm);
-
-signals:
- void downloadComplete(QByteArray assetData);
- void killDownloadThread();
-
-public slots:
- void doWork(QUrl assetUrl);
- void doneWork();
-
-protected:
- QNetworkAccessManager * getNetworkManager();
- void incrementRequestCount();
- void decrementRequestCount();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTHREADEDDOWNLOADMANAGER_P_H
diff --git a/src/threed/painting/painting.pri b/src/threed/painting/painting.pri
deleted file mode 100644
index 27763c09..00000000
--- a/src/threed/painting/painting.pri
+++ /dev/null
@@ -1,29 +0,0 @@
-
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- painting/qglabstracteffect.h \
- painting/qgllightmodel.h \
- painting/qgllightparameters.h \
- painting/qglpainter.h \
- painting/qmatrix4x4stack.h
-
-SOURCES += \
- qglabstracteffect.cpp \
- qglext.cpp \
- qgllightmodel.cpp \
- qgllightparameters.cpp \
- qglpainter.cpp \
- qglpickcolors.cpp \
- qmatrix4x4stack.cpp
-
-PRIVATE_HEADERS += \
- qglpainter_p.h \
- qglpickcolors_p.h \
- qglabstracteffect_p.h \
- qmatrix4x4stack_p.h
-
-# Don't add this file to PRIVATE_HEADERS because we don't
-# want moc to run over it:
-# qglext_p.h
diff --git a/src/threed/painting/qglabstracteffect.cpp b/src/threed/painting/qglabstracteffect.cpp
deleted file mode 100644
index 756d15bf..00000000
--- a/src/threed/painting/qglabstracteffect.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglabstracteffect.h"
-#include "qglpainter_p.h"
-#include <QtOpenGL/qglshaderprogram.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAbstractEffect
- \since 4.8
- \brief The QGLAbstractEffect class provides a standard interface for rendering surface material effects with GL.
- \ingroup qt3d
- \ingroup qt3d::painting
-
- \section1 Vertex attributes
-
- Vertex attributes for the effect are specified using
- QGLPainter::setVertexAttribute() and QGLPainter::setVertexBundle(),
- and may be independent of the effect itself. Those functions
- will bind standard attributes to specific indexes within the
- GL state. For example, the QGL::Position will be bound
- to index 0, QGL::TextureCoord0 will be bound to index 3, etc.
-
- Effect subclasses that use vertex shaders should bind their attributes
- to these indexes using QGLShaderProgram::bindAttributeLocation()
- just before the program is linked. For example:
-
- \code
- QGLShaderProgram *program = new QGLShaderProgram();
- program->addShaderFromSourceCode(QGLShader::Vertex, vshaderSource);
- program->addShaderFromSourceCode(QGLShader::Fragment, fshaderSource);
- program->bindAttributeLocation("vertex", QGL::Position);
- program->bindAttributeLocation("normal", QGL::Normal);
- program->bindAttributeLocation("texcoord", QGL::TextureCoord0);
- program->link();
- \endcode
-
- The QGLShaderProgramEffect class can assist with writing
- shader-based effects. It will automatically bind special
- variable names, such as \c{qt_Vertex}, \c{qt_MultiTexCoord0}, etc,
- to the standard indexes. This alleviates the need for the
- application to bind the names itself.
-*/
-
-/*!
- Constructs a new effect object.
-*/
-QGLAbstractEffect::QGLAbstractEffect()
-{
-}
-
-/*!
- Destroys this effect object.
-*/
-QGLAbstractEffect::~QGLAbstractEffect()
-{
-}
-
-/*!
- Returns true if this effect supports object picking; false otherwise.
- The default implementation returns false, which causes QGLPainter
- to use the effect associated with QGL::FlatColor to perform
- object picking.
-
- Effects that support object picking render fragments with
- QGLPainter::pickColor() when QGLPainter::isPicking() returns true.
- By default, only the effect associated with QGL::FlatColor does this,
- rendering the entire fragment with the flat pick color.
-
- In some cases, rendering the entire fragment with the pick color
- may not be appropriate. An alpha-blended icon texture that is
- drawn to the screen as a quad may have an irregular shape smaller
- than the quad. For picking, the application may not want the
- entire quad to be "active" for object selection as it would appear
- to allow the user to click off the icon to select it.
-
- This situation can be handled by implementing an icon rendering
- effect that draws the icon normally when QGLPainter::isPicking()
- is false, and draws a mask texture defining the outline of the icon
- with QGLPainter::pickColor() when QGLPainter::isPicking() is true.
-
- \sa QGLPainter::setPicking()
-*/
-bool QGLAbstractEffect::supportsPicking() const
-{
- return false;
-}
-
-/*!
- \fn void QGLAbstractEffect::setActive(QGLPainter *painter, bool flag)
-
- Activates or deactivates this effect on \a painter,
- according to \a flag, on the current GL context by selecting
- shader programs, setting lighting and material parameters, etc.
-
- \sa update()
-*/
-
-/*!
- \fn void QGLAbstractEffect::update(QGLPainter *painter, QGLPainter::Updates updates)
-
- Updates the current GL context with information from \a painter
- just prior to the drawing of triangles, quads, etc.
-
- The \a updates parameter specifies the properties on \a painter
- that have changed since the last call to update() or setActive().
-
- \sa setActive()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qglabstracteffect.h b/src/threed/painting/qglabstracteffect.h
deleted file mode 100644
index ad317f69..00000000
--- a/src/threed/painting/qglabstracteffect.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLABSTRACTEFFECT_H
-#define QGLABSTRACTEFFECT_H
-
-#include "qglpainter.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLAbstractEffect
-{
-public:
- QGLAbstractEffect();
- virtual ~QGLAbstractEffect();
-
- virtual bool supportsPicking() const;
- virtual void setActive(QGLPainter *painter, bool flag) = 0;
- virtual void update(QGLPainter *painter, QGLPainter::Updates updates) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qglabstracteffect_p.h b/src/threed/painting/qglabstracteffect_p.h
deleted file mode 100644
index 57f2a338..00000000
--- a/src/threed/painting/qglabstracteffect_p.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLABSTRACTEFFECT_P_H
-#define QGLABSTRACTEFFECT_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.
-//
-
-#include "qglabstracteffect.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-#if defined(QT_OPENGL_ES_2)
-#define QGL_SHADERS_ONLY 1
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qglext.cpp b/src/threed/painting/qglext.cpp
deleted file mode 100644
index 82ab179f..00000000
--- a/src/threed/painting/qglext.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglext_p.h"
-#include "qopenglfunctions.h"
-
-// copied private header
-#include "qglextensions_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_OPENGL_ES)
-
-typedef void (QT3D_GLF_APIENTRYP q_PFNGLCLIENTACTIVETEXTUREPROC) (GLenum);
-
-class QGLMultiTextureExtensions
-{
-public:
- QGLMultiTextureExtensions(const QGLContext * = 0)
- {
- clientActiveTexture = 0;
- multiTextureResolved = false;
- }
-
- q_PFNGLCLIENTACTIVETEXTUREPROC clientActiveTexture;
- bool multiTextureResolved;
-};
-
-Q_GLOBAL_STATIC(QGLResource<QGLMultiTextureExtensions>, qt_multitexture_funcs)
-
-static QGLMultiTextureExtensions *resolveMultiTextureExtensions
- (const QGLContext *ctx)
-{
- QGLMultiTextureExtensions *extn = qt_multitexture_funcs()->value(ctx);
- if (!(extn->multiTextureResolved)) {
- extn->multiTextureResolved = true;
- if (!extn->clientActiveTexture) {
- extn->clientActiveTexture = (q_PFNGLCLIENTACTIVETEXTUREPROC)
- ctx->getProcAddress(QLatin1String("glClientActiveTexture"));
- }
- if (!extn->clientActiveTexture) {
- extn->clientActiveTexture = (q_PFNGLCLIENTACTIVETEXTUREPROC)
- ctx->getProcAddress(QLatin1String("glClientActiveTextureARB"));
- }
- }
- return extn;
-}
-
-void qt_gl_ClientActiveTexture(GLenum texture)
-{
- const QGLContext *ctx = QGLContext::currentContext();
- if (!ctx)
- return;
- QGLMultiTextureExtensions *extn = resolveMultiTextureExtensions(ctx);
- if (extn->clientActiveTexture)
- extn->clientActiveTexture(texture);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qglext_p.h b/src/threed/painting/qglext_p.h
deleted file mode 100644
index c2999c80..00000000
--- a/src/threed/painting/qglext_p.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLEXT_P_H
-#define QGLEXT_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.
-//
-
-#include <QtOpenGL/qgl.h>
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-// Provide some useful OpenGL extension definitions.
-
-#if !defined(QT_OPENGL_ES)
-
-extern void Q_QT3D_EXPORT qt_gl_ClientActiveTexture(GLenum texture);
-
-#elif !defined(QT_OPENGL_ES_2)
-
-#define qt_gl_ClientActiveTexture glClientActiveTexture
-
-#endif
-
-class QGLExtensionChecker
-{
-public:
- QGLExtensionChecker(const char *str)
- : gl_extensions(str), gl_extensions_length(qstrlen(str))
- {}
-
- bool match(const char *str) {
- int str_length = qstrlen(str);
- const char *extensions = gl_extensions;
- int extensions_length = gl_extensions_length;
-
- while (1) {
- // the total length that needs to be matched is the str_length +
- // the space character that terminates the extension name
- if (extensions_length < str_length + 1)
- return false;
- if (qstrncmp(extensions, str, str_length) == 0 && extensions[str_length] == ' ')
- return true;
-
- int split_pos = 0;
- while (split_pos < extensions_length && extensions[split_pos] != ' ')
- ++split_pos;
- ++split_pos; // added for the terminating space character
- extensions += split_pos;
- extensions_length -= split_pos;
- }
- return false;
- }
-
-private:
- const char *gl_extensions;
- int gl_extensions_length;
-};
-
-// Copy of some definitions from <QtOpenGL/private/qgl_p.h> so that
-// we can avoid a direct dependency upon private headers in Qt.
-
-#if QT_VERSION >= 0x040800
-
-class QGLContextGroup;
-
-#if !defined(QGL_P_H)
-
-class Q_OPENGL_EXPORT QGLContextGroupResourceBase
-{
-public:
- QGLContextGroupResourceBase();
- virtual ~QGLContextGroupResourceBase();
- void insert(const QGLContext *context, void *value);
- void *value(const QGLContext *context);
- void cleanup(const QGLContext *context, void *value);
- virtual void freeResource(void *value) = 0;
-
-protected:
- QList<QGLContextGroup *> m_groups;
-
-private:
- QAtomicInt active;
-};
-
-#endif
-
-template <class T>
-class QGLResource : public QGLContextGroupResourceBase
-{
-public:
- T *value(const QGLContext *context) {
- T *resource = reinterpret_cast<T *>(QGLContextGroupResourceBase::value(context));
- if (!resource) {
- resource = new T(context);
- insert(context, resource);
- }
- return resource;
- }
-
-protected:
- void freeResource(void *resource) {
- delete reinterpret_cast<T *>(resource);
- }
-};
-
-#else
-
-#if !defined(QGL_P_H)
-
-class Q_OPENGL_EXPORT QGLContextResource
-{
-public:
- typedef void (*FreeFunc)(void *);
- QGLContextResource(FreeFunc f);
- ~QGLContextResource();
- void insert(const QGLContext *key, void *value);
- void *value(const QGLContext *key);
- void cleanup(const QGLContext *ctx, void *value);
-private:
- FreeFunc free;
- QAtomicInt active;
-};
-
-#endif
-
-template <class T>
-class QGLResource : public QGLContextResource
-{
-public:
- static void freeResource(void *resource) {
- delete reinterpret_cast<T *>(resource);
- }
-
- QGLResource() : QGLContextResource(freeResource) {}
-
- T *value(const QGLContext *context) {
- T *resource = reinterpret_cast<T *>(QGLContextResource::value(context));
- if (!resource) {
- resource = new T(context);
- insert(context, resource);
- }
- return resource;
- }
-};
-
-#endif
-
-#if !defined(QGL_P_H) && !defined(Q_MOC_RUN)
-
-class Q_OPENGL_EXPORT QGLSignalProxy : public QObject
-{
- Q_OBJECT
-public:
- QGLSignalProxy() : QObject() {}
- void emitAboutToDestroyContext(const QGLContext *context) {
- emit aboutToDestroyContext(context);
- }
- static QGLSignalProxy *instance();
-Q_SIGNALS:
- void aboutToDestroyContext(const QGLContext *context);
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qgllightmodel.cpp b/src/threed/painting/qgllightmodel.cpp
deleted file mode 100644
index f68c1179..00000000
--- a/src/threed/painting/qgllightmodel.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgllightmodel.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLLightModel
- \brief The QGLLightModel class defines the lighting model to use for the scene.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-*/
-
-/*!
- \qmlclass LightModel QGLLightModel
- \brief The LightModel item defines the lighting model to use for the scene.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \sa Light
-*/
-
-/*!
- \enum QGLLightModel::Model
- This enum defines the type of lighting model to use: one-sided or two-sided.
-
- \value OneSided One-sided lighting, with the front face material used for both front and back faces.
- \value TwoSided Two-sided lighting, with separate front and back face materials.
-*/
-
-/*!
- \enum QGLLightModel::ColorControl
- This enum controls the number of colors to be generated by the lighting computation.
-
- \value SingleColor A single color is generated by the lighting computation.
- \value SeparateSpecularColor A separate specular color computation is
- performed and then summed into the pixel color after texture mapping.
-*/
-
-/*!
- \enum QGLLightModel::ViewerPosition
- This enum defines the position of the viewer for the purposes of lighting calculations.
-
- \value ViewerAtInfinity The viewer is at infinity along the -z axis.
- \value LocalViewer The viewer is at the local origin in eye coordinates.
-*/
-
-class QGLLightModelPrivate
-{
-public:
- QGLLightModelPrivate()
- : model(QGLLightModel::OneSided),
- colorControl(QGLLightModel::SingleColor),
- viewerPosition(QGLLightModel::ViewerAtInfinity)
- {
- ambientSceneColor.setRgbF(0.2, 0.2, 0.2, 1.0);
- }
-
- QGLLightModel::Model model;
- QGLLightModel::ColorControl colorControl;
- QGLLightModel::ViewerPosition viewerPosition;
- QColor ambientSceneColor;
-};
-
-/*!
- Constructs a light model object with default values and attach
- it to \a parent.
-*/
-QGLLightModel::QGLLightModel(QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLLightModelPrivate)
-{
-}
-
-/*!
- Destroys this light model.
-*/
-QGLLightModel::~QGLLightModel()
-{
-}
-
-/*!
- \property QGLLightModel::model
- \brief the lighting model to use, either OneSided or TwoSided.
- The default is OneSided.
-
- \sa modelChanged()
-*/
-
-/*!
- \qmlproperty enumeration LightModel::model
- The lighting model to use, either OneSided or TwoSided.
- The default is OneSided.
-*/
-
-QGLLightModel::Model QGLLightModel::model() const
-{
- Q_D(const QGLLightModel);
- return d->model;
-}
-
-void QGLLightModel::setModel(QGLLightModel::Model value)
-{
- Q_D(QGLLightModel);
- if (d->model != value) {
- d->model = value;
- emit modelChanged();
- emit lightModelChanged();
- }
-}
-
-/*!
- \property QGLLightModel::colorControl
- \brief the color control mode, either SingleColor or
- SeparateSpecularColor. The default value is SingleColor.
-
- If SingleColor is specified, then a single color is calculated
- by the lighting computation for a vertex. If SeparateSpecularColor
- is specified, then a separate specular color computation is
- performed and then summed into the pixel color after texture mapping.
-
- \sa colorControlChanged()
-*/
-
-/*!
- \qmlproperty enumeration LightModel::colorControl
- The color control mode, either SingleColor or
- SeparateSpecularColor. The default value is SingleColor.
-
- If SingleColor is specified, then a single color is calculated
- by the lighting computation for a vertex. If SeparateSpecularColor
- is specified, then a separate specular color computation is
- performed and then summed into the pixel color after texture mapping.
-*/
-
-QGLLightModel::ColorControl QGLLightModel::colorControl() const
-{
- Q_D(const QGLLightModel);
- return d->colorControl;
-}
-
-void QGLLightModel::setColorControl(QGLLightModel::ColorControl value)
-{
- Q_D(QGLLightModel);
- if (d->colorControl != value) {
- d->colorControl = value;
- emit colorControlChanged();
- emit lightModelChanged();
- }
-}
-
-/*!
- \property QGLLightModel::viewerPosition
- \brief the viewer position, either ViewerAtInfinity or LocalViewer.
- The default value is ViewerAtInfinity.
-
- \sa viewerPositionChanged()
-*/
-
-/*!
- \qmlproperty enumeration LightModel::viewerPosition
- The viewer position, either ViewerAtInfinity or LocalViewer.
- The default value is ViewerAtInfinity.
-*/
-
-QGLLightModel::ViewerPosition QGLLightModel::viewerPosition() const
-{
- Q_D(const QGLLightModel);
- return d->viewerPosition;
-}
-
-void QGLLightModel::setViewerPosition(QGLLightModel::ViewerPosition value)
-{
- Q_D(QGLLightModel);
- if (d->viewerPosition != value) {
- d->viewerPosition = value;
- emit viewerPositionChanged();
- emit lightModelChanged();
- }
-}
-
-/*!
- \property QGLLightModel::ambientSceneColor
- \brief the ambient color of the entire scene. The default value
- is (0.2, 0.2, 0.2, 1.0).
-
- \sa ambientSceneColorChanged()
-*/
-
-/*!
- \qmlproperty color LightModel::ambientSceneColor
- The ambient color of the entire scene. The default value
- is (0.2, 0.2, 0.2, 1.0).
-*/
-
-QColor QGLLightModel::ambientSceneColor() const
-{
- Q_D(const QGLLightModel);
- return d->ambientSceneColor;
-}
-
-void QGLLightModel::setAmbientSceneColor(const QColor& value)
-{
- Q_D(QGLLightModel);
- if (d->ambientSceneColor != value) {
- d->ambientSceneColor = value;
- emit ambientSceneColorChanged();
- emit lightModelChanged();
- }
-}
-
-/*!
- \fn void QGLLightModel::modelChanged()
-
- This signal is emitted when model() changes.
-
- \sa model(), lightModelChanged()
-*/
-
-/*!
- \fn void QGLLightModel::colorControlChanged()
-
- This signal is emitted when colorControl() changes.
-
- \sa colorControl(), lightModelChanged()
-*/
-
-/*!
- \fn void QGLLightModel::viewerPositionChanged()
-
- This signal is emitted when viewerPosition() changes.
-
- \sa viewerPosition(), lightModelChanged()
-*/
-
-/*!
- \fn void QGLLightModel::ambientSceneColorChanged()
-
- This signal is emitted when ambientSceneColor() changes.
-
- \sa ambientSceneColor(), lightModelChanged()
-*/
-
-/*!
- \fn void QGLLightModel::lightModelChanged()
-
- This signal is emitted when one of model(), colorControl(),
- viewerPosition(), or ambientSceneColor() changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qgllightmodel.h b/src/threed/painting/qgllightmodel.h
deleted file mode 100644
index 1ffde57a..00000000
--- a/src/threed/painting/qgllightmodel.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLLIGHTMODEL_H
-#define QGLLIGHTMODEL_H
-
-#include "qt3dglobal.h"
-#include <QtCore/qobject.h>
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLLightModelPrivate;
-
-class Q_QT3D_EXPORT QGLLightModel : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLLightModel)
- Q_ENUMS(Model)
- Q_ENUMS(ColorControl)
- Q_ENUMS(ViewerPosition)
- Q_PROPERTY(Model model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(ColorControl colorControl READ colorControl WRITE setColorControl NOTIFY colorControlChanged)
- Q_PROPERTY(ViewerPosition viewerPosition READ viewerPosition WRITE setViewerPosition NOTIFY viewerPositionChanged)
- Q_PROPERTY(QColor ambientSceneColor READ ambientSceneColor WRITE setAmbientSceneColor NOTIFY ambientSceneColorChanged)
-public:
- explicit QGLLightModel(QObject *parent = 0);
- ~QGLLightModel();
-
- enum Model
- {
- OneSided,
- TwoSided
- };
-
- enum ColorControl
- {
- SingleColor,
- SeparateSpecularColor
- };
-
- enum ViewerPosition
- {
- ViewerAtInfinity,
- LocalViewer
- };
-
- QGLLightModel::Model model() const;
- void setModel(QGLLightModel::Model value);
-
- QGLLightModel::ColorControl colorControl() const;
- void setColorControl(QGLLightModel::ColorControl value);
-
- QGLLightModel::ViewerPosition viewerPosition() const;
- void setViewerPosition(QGLLightModel::ViewerPosition value);
-
- QColor ambientSceneColor() const;
- void setAmbientSceneColor(const QColor& value);
-
-Q_SIGNALS:
- void modelChanged();
- void colorControlChanged();
- void viewerPositionChanged();
- void ambientSceneColorChanged();
- void lightModelChanged();
-
-private:
- Q_DISABLE_COPY(QGLLightModel)
-
- QScopedPointer<QGLLightModelPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qgllightparameters.cpp b/src/threed/painting/qgllightparameters.cpp
deleted file mode 100644
index d96bf162..00000000
--- a/src/threed/painting/qgllightparameters.cpp
+++ /dev/null
@@ -1,828 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgllightparameters.h"
-#include <QtCore/qmath.h>
-#include <QtGui/qmatrix4x4.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLLightParameters
- \brief The QGLLightParameters class represents the parameters of a light in a 3D scene.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-
- The functions in this class are a convenience wrapper for the OpenGL enumerations
- which control each light source in a 3D scene. For the general ambient light in a
- scene, not from a source refer to QGLLightModel.
-
- The ambient, diffuse and specular components of the light can be controlled for by
- colour, and are set by the following functions:
- \list
- \o setAmbientColor()
- \o setDiffuseColor()
- \o setSpecularColor()
- \endlist
- Other than changing intensity by using darker color values, see below for how to
- change the intensity of the light with distance from the lit object.
-
- Light sources are of two types, directional and positional, described by the
- enumeration QGLLightParameters::LightType. By default a light source is directional.
-
- A directional light source is infinitely distant, such that its rays are all
- parallel, to a direction \bold vector. This vector is set by the setDirection()
- function. If the light source is not directional when setDirection() is called, its
- type is changed to Directional. Directional light sources model real world light
- sources like the sun. Such light sources are not located at any particular point
- and affect the scene evenly.
-
- In the OpenGL model-view, a directional light is represented by a 4d vector, with
- the 4th value, \c w, set to 0.0f. This means that the spatial data of the light
- is not changed during certain transformations, for example translation.
- See \l {3D Math Basis} for a fuller explanation of this.
-
- Calling the setPosition() function defines the light source to be located at a given
- \bold point, a finite distance from the lit object. If the light source is not
- positional when this function is called its type is changed to Positional.
-
- A positional light source models a real world lamp, such as a light-bulb or
- car headlight. Since it is a finite distance from the lit object the rays diverge
- and lighting calculations are thus more complex.
-
- In OpenGL the light has its spatial data \c w value set to 1.0f, resulting in the
- lights position being changed along with other objects in the scene by transformations
- such as translation. See \l {3D Math Basis} for more.
-
- Positional lights are by default point sources, like the light-bulb where light
- radiates in all directions. Calling the spotAngle() function sets an angle to
- restrict the light from a positional source to a cone like the car headlight. This
- makes the light behave like a spotlight, where objects outside of the cone of the
- light do not receive any light from that source.
-
- The spotlight may be further specified by its spotExponent() which dictates the
- behaviour of the cutoff at the lighting cone; and by the attenuation functions
- which are the terms in the following equation:
- \image attenuation.png
- here \c d is the distance of the light from the lit object, and A is the attenuation
- factor which is a multiplier of the light source, determining its intensity at the
- lit object. The terms in the denominator are:
- \list
- \o constantAttenuation() - default 1.0
- \raw HTML
- k<sub>c</sub>
- \endraw
- \o linearAttenuation() - default 0.0
- \raw HTML
- k<sub>l</sub>
- \endraw
- \o quadraticAttenuation() - default 0.0
- \raw HTML
- k<sub>q</sub>
- \endraw
- \endlist
- When these terms are large the light contributed by the source becomes much weaker
- with distance from the object.
-*/
-
-/*!
- \qmlclass Light QGLLightParameters
- \brief The Light item represents the parameters of a light in a 3D scene.
- \since 4.8
- \ingroup qt3d::qml3d
-
- \sa LightModel
-*/
-
-class QGLLightParametersPrivate
-{
-public:
- QGLLightParametersPrivate() :
- type(QGLLightParameters::Directional),
- position(0.0f, 0.0f, 1.0f),
- ambientColor(0, 0, 0, 255),
- diffuseColor(255, 255, 255, 255),
- specularColor(255, 255, 255, 255),
- spotDirection(0.0f, 0.0f, -1.0f),
- spotExponent(0.0f),
- spotAngle(180.0f),
- spotCosAngle(-1.0f),
- constantAttenuation(1.0f),
- linearAttenuation(0.0f),
- quadraticAttenuation(0.0f)
- {
- }
-
- QGLLightParameters::LightType type;
- QVector3D position;
- QColor ambientColor;
- QColor diffuseColor;
- QColor specularColor;
- QVector3D spotDirection;
- qreal spotExponent;
- qreal spotAngle;
- qreal spotCosAngle;
- qreal constantAttenuation;
- qreal linearAttenuation;
- qreal quadraticAttenuation;
-};
-
-
-/*!
- \enum QGLLightParameters::LightType
- This enum defines the possible types of light.
-
- \value Directional The default. Directional lights are infinitely
- distant from the lit object, and its rays are parallel to a
- direction vector. Use setDirection() to make a light Directional.
- \value Positional Positional lights are a finite distance from the
- lit object. Complex lighting with spot-lights, and attenuation
- are enabled with Positional lighting. Use setPosition() to
- make a light Positional.
-*/
-
-/*!
- Constructs a new light parameters object with default values
- and attaches it to \a parent.
-*/
-QGLLightParameters::QGLLightParameters(QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLLightParametersPrivate)
-{
-}
-
-/*!
- Destroys this light parameters object.
-*/
-QGLLightParameters::~QGLLightParameters()
-{
-}
-
-/*!
- \property QGLLightParameters::type
- \brief the type of this light; Positional or Directional.
-
- \sa position(), direction()
-*/
-
-/*!
- \qmlproperty enumeration Light::type
- The type of this light; Positional or Directional. The default
- is Directional.
-
- \sa position, direction
-*/
-
-QGLLightParameters::LightType QGLLightParameters::type() const
-{
- Q_D(const QGLLightParameters);
- return d->type;
-}
-
-/*!
- \property QGLLightParameters::position
- \brief the position of this light if it is Positional; or a null
- QVector3D if it is Directional. By default, the light is Directional.
-
- For a Positional light, the return value is the location in model space
- of the light, at some finite distance from the origin. The value is
- transformed by the model-view transformation when the light
- parameters are applied.
-
- When the light is Positional OpenGL will obey other parameters relating
- to the light's position, such as attenuation and spot angle.
-
- Setting the position converts the light from Directional to Positional.
-
- \sa direction(), type(), positionChanged()
-*/
-
-/*!
- \qmlproperty vector3D Light::position
- The position of this light if it is Positional; or a zero vector
- if it is Directional. By default, the light is Directional.
-
- For a Positional light, the return value is the location in model space
- of the light, at some finite distance from the origin. The value is
- transformed by the model-view transformation when the light
- parameters are applied.
-
- When the light is Positional OpenGL will obey other parameters relating
- to the light's position, such as attenuation and spot angle.
-
- Setting the position converts the light from Directional to Positional.
-
- \sa direction, type
-*/
-
-QVector3D QGLLightParameters::position() const
-{
- Q_D(const QGLLightParameters);
- if (d->type == Positional)
- return d->position;
- else
- return QVector3D();
-}
-
-void QGLLightParameters::setPosition(const QVector3D& point)
-{
- Q_D(QGLLightParameters);
- if (d->type == Positional) {
- if (d->position != point) {
- // Only the position() has changed.
- d->position = point;
- emit positionChanged();
- emit lightChanged();
- }
- } else {
- // Both the position() and direction() are changed.
- d->type = Positional;
- d->position = point;
- emit positionChanged();
- emit directionChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::direction
- \brief the direction of this light if it is Directional; or a null
- QVector3D if it is Positional. By default, the light is Directional.
-
- For a Directional light, the return value is the direction vector of
- an infinitely distant directional light, like the sun.
-
- The default value is (0, 0, 1), for a directional light pointing along
- the positive z-axis.
-
- OpenGL will ignore other parameters such as attenuation and spot angle
- when this value is set, since a directional light has no location.
- In order to set the direction of a spot light, use the setSpotDirection()
- function.
-
- Setting the direction converts the light from Positional to Directional.
-
- \sa position(), type(), directionChanged()
-*/
-
-/*!
- \qmlproperty vector3D Light::direction
- The direction of this light if it is Directional; or a zero vector
- if it is Positional. By default, the light is Directional.
-
- For a Directional light, the return value is the direction vector of
- an infinitely distant directional light, like the sun.
-
- The default value is (0, 0, 1), for a directional light pointing along
- the positive z-axis.
-
- OpenGL will ignore other parameters such as attenuation and spot angle
- when this value is set, since a directional light has no location.
- In order to set the direction of a spot light, use the setSpotDirection()
- function.
-
- Setting the direction converts the light from Positional to Directional.
-
- \sa position, type
-*/
-
-QVector3D QGLLightParameters::direction() const
-{
- Q_D(const QGLLightParameters);
- if (d->type == Directional)
- return d->position;
- else
- return QVector3D();
-}
-
-void QGLLightParameters::setDirection(const QVector3D& value)
-{
- Q_D(QGLLightParameters);
- if (d->type == Directional) {
- if (d->position != value) {
- // Only the direction() has changed.
- d->position = value;
- emit directionChanged();
- emit lightChanged();
- }
- } else {
- // Both the position() and direction() are changed.
- d->type = Directional;
- d->position = value;
- emit positionChanged();
- emit directionChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::ambientColor
- \brief the ambient color of this light. The default value is black.
-
- \sa diffuseColor(), specularColor(), ambientColorChanged()
-*/
-
-/*!
- \qmlproperty color Light::ambientColor
- The ambient color of this light. The default value is black.
-
- \sa diffuseColor, specularColor
-*/
-
-QColor QGLLightParameters::ambientColor() const
-{
- Q_D(const QGLLightParameters);
- return d->ambientColor;
-}
-
-void QGLLightParameters::setAmbientColor(const QColor& value)
-{
- Q_D(QGLLightParameters);
- if (d->ambientColor != value) {
- d->ambientColor = value;
- emit ambientColorChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::diffuseColor
- \brief the diffuse color of this light. The default value is white.
-
- \sa ambientColor(), specularColor(), diffuseColorChanged()
-*/
-
-/*!
- \qmlproperty color Light::diffuseColor
- The diffuse color of this light. The default value is white.
-
- \sa ambientColor, specularColor
-*/
-QColor QGLLightParameters::diffuseColor() const
-{
- Q_D(const QGLLightParameters);
- return d->diffuseColor;
-}
-
-void QGLLightParameters::setDiffuseColor(const QColor& value)
-{
- Q_D(QGLLightParameters);
- if (d->diffuseColor != value) {
- d->diffuseColor = value;
- emit diffuseColorChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::specularColor
- \brief the specular color of this light. The default value is white.
-
- \sa ambientColor(), diffuseColor(), specularColorChanged()
-*/
-
-/*!
- \qmlproperty color Light::specularColor
- The specular color of this light. The default value is white.
-
- \sa ambientColor, diffuseColor
-*/
-
-QColor QGLLightParameters::specularColor() const
-{
- Q_D(const QGLLightParameters);
- return d->specularColor;
-}
-
-void QGLLightParameters::setSpecularColor(const QColor& value)
-{
- Q_D(QGLLightParameters);
- if (d->specularColor != value) {
- d->specularColor = value;
- emit specularColorChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::spotDirection
- \brief the direction that a spot-light is shining in.
-
- A spotlight is a positional light that has a value other than the default
- for spot angle. The default value is (0, 0, -1).
-
- This parameter has no effect on a Directional light.
-
- \sa spotExponent(), spotDirectionChanged()
-*/
-
-/*!
- \qmlproperty vector3D Light::spotDirection
- The direction that a spot-light is shining in.
-
- A spotlight is a positional light that has a value other than the default
- for spot angle. The default value is (0, 0, -1).
-
- This parameter has no effect on a Directional light.
-
- \sa spotExponent
-*/
-QVector3D QGLLightParameters::spotDirection() const
-{
- Q_D(const QGLLightParameters);
- return d->spotDirection;
-}
-
-void QGLLightParameters::setSpotDirection(const QVector3D& vector)
-{
- Q_D(QGLLightParameters);
- if (d->spotDirection != vector) {
- d->spotDirection = vector;
- emit spotDirectionChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::spotExponent
- \brief the exponent value between 0 and 128 that indicates the
- intensity distribution of a spot-light. The default value is 0,
- indicating uniform light distribution.
-
- This parameter has no effect on a Directional light.
-
- \sa spotAngle(), setPosition(), spotExponentChanged()
-*/
-
-/*!
- \qmlproperty real Light::spotExponent
- The exponent value between 0 and 128 that indicates the
- intensity distribution of a spot-light. The default value is 0,
- indicating uniform light distribution.
-
- This parameter has no effect on a Directional light.
-
- \sa spotAngle, position
-*/
-
-qreal QGLLightParameters::spotExponent() const
-{
- Q_D(const QGLLightParameters);
- return d->spotExponent;
-}
-
-void QGLLightParameters::setSpotExponent(qreal value)
-{
- Q_D(QGLLightParameters);
- if (d->spotExponent != value) {
- d->spotExponent = value;
- emit spotExponentChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::spotAngle
- \brief the angle over which light is spread from this light.
- It should be between 0 and 90 for spot lights, and 180 for
- uniform light distribution from a remote light source.
- The default value is 180.
-
- This parameter has no effect on a Directional light.
-
- \sa spotCosAngle(), spotAngleChanged()
-*/
-
-/*!
- \qmlproperty real Light::spotAngle
- The angle over which light is spread from this light.
- It should be between 0 and 90 for spot lights, and 180 for
- uniform light distribution from a remote light source.
- The default value is 180.
-
- This parameter has no effect on a Directional light.
-*/
-
-qreal QGLLightParameters::spotAngle() const
-{
- Q_D(const QGLLightParameters);
- return d->spotAngle;
-}
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-void QGLLightParameters::setSpotAngle(qreal value)
-{
- Q_D(QGLLightParameters);
- if (d->spotAngle != value) {
- d->spotAngle = value;
- if (value != 180.0f)
- d->spotCosAngle = qCos(value * M_PI / 180.0f);
- else
- d->spotCosAngle = -1.0f;
- emit spotAngleChanged();
- emit lightChanged();
- }
-}
-
-/*!
- Returns the cosine of spotAngle(), or -1 if spotAngle() is 180.
-
- The cosine of spotAngle() is useful in lighting algorithms.
- This function returns a cached copy of the cosine so that it
- does not need to be computed every time the lighting parameters
- are read.
-
- \sa spotAngle()
-*/
-qreal QGLLightParameters::spotCosAngle() const
-{
- Q_D(const QGLLightParameters);
- return d->spotCosAngle;
-}
-
-/*!
- \property QGLLightParameters::constantAttenuation
- \brief the constant light attenuation factor. The default value is 1.
-
- This parameter has no effect on a Directional light.
-
- \sa linearAttenuation(), quadraticAttenuation()
- \sa constantAttenuationChanged()
-*/
-
-/*!
- \qmlproperty real Light::constantAttenuation
- The constant light attenuation factor. The default value is 1.
-
- This parameter has no effect on a Directional light.
-
- \sa linearAttenuation, quadraticAttenuation
-*/
-
-qreal QGLLightParameters::constantAttenuation() const
-{
- Q_D(const QGLLightParameters);
- return d->constantAttenuation;
-}
-
-void QGLLightParameters::setConstantAttenuation(qreal value)
-{
- Q_D(QGLLightParameters);
- if (d->constantAttenuation != value) {
- d->constantAttenuation = value;
- emit constantAttenuationChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::linearAttenuation
- \brief the linear light attenuation factor. The default value is 0.
-
- This parameter has no effect on a Directional light.
-
- \sa constantAttenuation(), quadraticAttenuation()
- \sa linearAttenuationChanged()
-*/
-
-/*!
- \qmlproperty real Light::linearAttenuation
- The linear light attenuation factor. The default value is 0.
-
- This parameter has no effect on a Directional light.
-
- \sa constantAttenuation, quadraticAttenuation
-*/
-
-qreal QGLLightParameters::linearAttenuation() const
-{
- Q_D(const QGLLightParameters);
- return d->linearAttenuation;
-}
-
-void QGLLightParameters::setLinearAttenuation(qreal value)
-{
- Q_D(QGLLightParameters);
- if (d->linearAttenuation != value) {
- d->linearAttenuation = value;
- emit linearAttenuationChanged();
- emit lightChanged();
- }
-}
-
-/*!
- \property QGLLightParameters::quadraticAttenuation
- \brief the quadratic light attenuation factor. The default value is 0.
-
- This parameter has no effect on a Directional light.
-
- \sa constantAttenuation(), linearAttenuation()
- \sa quadraticAttenuationChanged()
-*/
-
-/*!
- \qmlproperty real Light::quadraticAttenuation
- The quadratic light attenuation factor. The default value is 0.
-
- This parameter has no effect on a Directional light.
-
- \sa constantAttenuation, linearAttenuation
-*/
-
-qreal QGLLightParameters::quadraticAttenuation() const
-{
- Q_D(const QGLLightParameters);
- return d->quadraticAttenuation;
-}
-
-void QGLLightParameters::setQuadraticAttenuation(qreal value)
-{
- Q_D(QGLLightParameters);
- if (d->quadraticAttenuation != value) {
- d->quadraticAttenuation = value;
- emit quadraticAttenuationChanged();
- emit lightChanged();
- }
-}
-
-/*!
- Returns the position of this light after transforming it from
- world co-ordinates to eye co-ordinates using \a transform.
-
- If the light is Directional, then direction() will be transformed,
- after setting the w co-ordinate to 0. If the light is Positional,
- then position() will be transformed after setting the w co-ordinate
- to 1.
-
- The returned result is suitable to be applied to the GL_POSITION
- property of \c{glLight()}, assuming that the modelview transformation
- in the GL context is set to the identity.
-
- \sa eyeSpotDirection()
-*/
-QVector4D QGLLightParameters::eyePosition(const QMatrix4x4& transform) const
-{
- Q_D(const QGLLightParameters);
- if (d->type == Directional)
- return transform * QVector4D(d->position, 0.0f);
- else
- return transform * QVector4D(d->position, 1.0f);
-}
-
-/*!
- Returns the spotDirection() for this light after transforming it
- from world co-ordinates to eye co-ordinates using the top-left
- 3x3 submatrix within \a transform.
-
- The returned result is suitable to be applied to the GL_SPOT_DIRECTION
- property of \c{glLight()}, assuming that the modelview transformation
- in the GL context is set to the identity.
-
- \sa eyePosition()
-*/
-QVector3D QGLLightParameters::eyeSpotDirection
- (const QMatrix4x4& transform) const
-{
- Q_D(const QGLLightParameters);
- return transform.mapVector(d->spotDirection);
-}
-
-/*!
- \fn void QGLLightParameters::positionChanged()
-
- This signal is emitted when position() changes, or when the type()
- changes between Directional and Positional.
-
- \sa position(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::directionChanged()
-
- This signal is emitted when direction() changes, or when the type()
- changes between Directional and Positional.
-
- \sa direction(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::ambientColorChanged()
-
- This signal is emitted when ambientColor() changes.
-
- \sa ambientColor(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::diffuseColorChanged()
-
- This signal is emitted when diffuseColor() changes.
-
- \sa diffuseColor(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::specularColorChanged()
-
- This signal is emitted when specularColor() changes.
-
- \sa specularColor(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::spotDirectionChanged()
-
- This signal is emitted when spotDirection() changes.
-
- \sa spotDirection(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::spotExponentChanged()
-
- This signal is emitted when spotExponent() changes.
-
- \sa spotExponent(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::spotAngleChanged()
-
- This signal is emitted when spotAngle() changes.
-
- \sa spotAngle(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::constantAttenuationChanged()
-
- This signal is emitted when constantAttenuation() changes.
-
- \sa constantAttenuation(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::linearAttenuationChanged()
-
- This signal is emitted when linearAttenuation() changes.
-
- \sa linearAttenuation(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::quadraticAttenuationChanged()
-
- This signal is emitted when quadraticAttenuation() changes.
-
- \sa quadraticAttenuation(), lightChanged()
-*/
-
-/*!
- \fn void QGLLightParameters::lightChanged()
-
- This signal is emitted when any of the properties on the light changes.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qgllightparameters.h b/src/threed/painting/qgllightparameters.h
deleted file mode 100644
index a2f3a709..00000000
--- a/src/threed/painting/qgllightparameters.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLLIGHTPARAMETERS_H
-#define QGLLIGHTPARAMETERS_H
-
-#include "qt3dglobal.h"
-#include <QtCore/qobject.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLLightParametersPrivate;
-class QMatrix4x4;
-
-class Q_QT3D_EXPORT QGLLightParameters : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLLightParameters)
- Q_ENUMS(LightType)
- Q_PROPERTY(LightType type READ type)
- Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
- Q_PROPERTY(QVector3D direction READ direction WRITE setDirection NOTIFY directionChanged)
- Q_PROPERTY(QColor ambientColor READ ambientColor WRITE setAmbientColor NOTIFY ambientColorChanged)
- Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
- Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged)
- Q_PROPERTY(QVector3D spotDirection READ spotDirection WRITE setSpotDirection NOTIFY spotDirectionChanged)
- Q_PROPERTY(qreal spotExponent READ spotExponent WRITE setSpotExponent NOTIFY spotExponentChanged)
- Q_PROPERTY(qreal spotAngle READ spotAngle WRITE setSpotAngle NOTIFY spotAngleChanged)
- Q_PROPERTY(qreal constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged)
- Q_PROPERTY(qreal linearAttenuation READ linearAttenuation WRITE setLinearAttenuation NOTIFY linearAttenuationChanged)
- Q_PROPERTY(qreal quadraticAttenuation READ quadraticAttenuation WRITE setQuadraticAttenuation NOTIFY quadraticAttenuationChanged)
-public:
- enum LightType {
- Directional,
- Positional
- };
-
- QGLLightParameters(QObject *parent = 0);
- ~QGLLightParameters();
-
- QGLLightParameters::LightType type() const;
-
- QVector3D position() const;
- void setPosition(const QVector3D& value);
-
- QVector3D direction() const;
- void setDirection(const QVector3D& value);
-
- QColor ambientColor() const;
- void setAmbientColor(const QColor& value);
-
- QColor diffuseColor() const;
- void setDiffuseColor(const QColor& value);
-
- QColor specularColor() const;
- void setSpecularColor(const QColor& value);
-
- QVector3D spotDirection() const;
- void setSpotDirection(const QVector3D& value);
-
- qreal spotExponent() const;
- void setSpotExponent(qreal value);
-
- qreal spotAngle() const;
- void setSpotAngle(qreal value);
-
- qreal spotCosAngle() const;
-
- qreal constantAttenuation() const;
- void setConstantAttenuation(qreal value);
-
- qreal linearAttenuation() const;
- void setLinearAttenuation(qreal value);
-
- qreal quadraticAttenuation() const;
- void setQuadraticAttenuation(qreal value);
-
- QVector4D eyePosition(const QMatrix4x4& transform) const;
- QVector3D eyeSpotDirection(const QMatrix4x4& transform) const;
-
-Q_SIGNALS:
- void positionChanged();
- void directionChanged();
- void ambientColorChanged();
- void diffuseColorChanged();
- void specularColorChanged();
- void spotDirectionChanged();
- void spotExponentChanged();
- void spotAngleChanged();
- void constantAttenuationChanged();
- void linearAttenuationChanged();
- void quadraticAttenuationChanged();
- void lightChanged();
-
-private:
- Q_DISABLE_COPY(QGLLightParameters)
-
- QScopedPointer<QGLLightParametersPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qglpainter.cpp b/src/threed/painting/qglpainter.cpp
deleted file mode 100644
index 3bf211cd..00000000
--- a/src/threed/painting/qglpainter.cpp
+++ /dev/null
@@ -1,2327 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglpainter.h"
-#include "qglpainter_p.h"
-#include "qglabstracteffect.h"
-#include "qglext_p.h"
-#include <QtOpenGL/qglpixelbuffer.h>
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qpaintengine.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qmap.h>
-#if !defined(QT_NO_THREAD)
-#include <QtCore/qthreadstorage.h>
-#endif
-#include "qglflatcoloreffect_p.h"
-#include "qglflattextureeffect_p.h"
-#include "qgllitmaterialeffect_p.h"
-#include "qgllittextureeffect_p.h"
-#include "qglpickcolors_p.h"
-#include "qgltexture2d.h"
-#include "qgltexturecube.h"
-#include "qgeometrydata.h"
-#include "qglvertexbundle_p.h"
-#include "qmatrix4x4stack_p.h"
-#include "qglwidgetsurface.h"
-#include "qglpixelbuffersurface.h"
-#include "qglpaintersurface_p.h"
-
-#undef glActiveTexture
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLPainter
- \brief The QGLPainter class provides portable API's for rendering into a GL context.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-
- TBD - lots of TBD
-
- All QGLPainter instances on a context share the same context state:
- matrices, effects, vertex attributes, etc. For example, calling
- ortho() on one QGLPainter instance for a context will alter the
- projectionMatrix() as seen by the other QGLPainter instances.
-*/
-
-/*!
- \enum QGLPainter::Update
- This enum defines the values that were changed since the last QGLPainter::update().
-
- \value UpdateColor The color has been updated.
- \value UpdateModelViewMatrix The modelview matrix has been updated.
- \value UpdateProjectionMatrix The projection matrix has been updated.
- \value UpdateMatrices The combination of UpdateModelViewMatrix and
- UpdateProjectionMatrix.
- \value UpdateLights The lights have been updated.
- \value UpdateMaterials The material parameters have been updated.
- \value UpdateViewport The viewport needs to be updated because the
- drawing surface has changed.
- \value UpdateAll All values have been updated. This is specified
- when an effect is activated.
-*/
-
-#define QGLPAINTER_CHECK_PRIVATE() \
- Q_ASSERT_X(d, "QGLPainter", "begin() has not been called or it failed")
-
-QGLPainterPrivate::QGLPainterPrivate()
- : ref(1),
- eye(QGL::NoEye),
- lightModel(0),
- defaultLightModel(0),
- defaultLight(0),
- frontMaterial(0),
- backMaterial(0),
- defaultMaterial(0),
- frontColorMaterial(0),
- backColorMaterial(0),
- viewingCube(QVector3D(-1, -1, -1), QVector3D(1, 1, 1)),
- color(255, 255, 255, 255),
- updates(QGLPainter::UpdateAll),
- pick(0),
- boundVertexBuffer(0),
- boundIndexBuffer(0),
- renderSequencer(0),
- isFixedFunction(true) // Updated by QGLPainter::begin()
-{
- context = 0;
- effect = 0;
- userEffect = 0;
- standardEffect = QGL::FlatColor;
- memset(stdeffects, 0, sizeof(stdeffects));
-}
-
-QGLPainterPrivate::~QGLPainterPrivate()
-{
- delete defaultLightModel;
- delete defaultLight;
- delete defaultMaterial;
- delete frontColorMaterial;
- delete backColorMaterial;
- for (int effect = 0; effect < QGL_MAX_STD_EFFECTS; ++effect)
- delete stdeffects[effect];
- delete pick;
- qDeleteAll(cachedPrograms);
- delete renderSequencer;
-}
-
-QGLPainterPickPrivate::QGLPainterPickPrivate()
-{
- isPicking = false;
- objectPickId = -1;
- pickColorIndex = -1;
- pickColor = 0;
- defaultPickEffect = new QGLFlatColorEffect();
-}
-
-QGLPainterPickPrivate::~QGLPainterPickPrivate()
-{
- delete defaultPickEffect;
-}
-
-#if !defined(QT_NO_THREAD)
-
-// QGLContext's are thread-specific, so QGLPainterPrivateCache should be too.
-
-typedef QThreadStorage<QGLPainterPrivateCache *> QGLPainterPrivateStorage;
-Q_GLOBAL_STATIC(QGLPainterPrivateStorage, painterPrivateStorage)
-static QGLPainterPrivateCache *painterPrivateCache()
-{
- QGLPainterPrivateCache *cache = painterPrivateStorage()->localData();
- if (!cache) {
- cache = new QGLPainterPrivateCache();
- painterPrivateStorage()->setLocalData(cache);
- }
- return cache;
-}
-
-#else
-
-Q_GLOBAL_STATIC(QGLPainterPrivateCache, painterPrivateCache)
-
-#endif
-
-QGLPainterPrivateCache::QGLPainterPrivateCache()
-{
- connect(QGLSignalProxy::instance(),
- SIGNAL(aboutToDestroyContext(const QGLContext *)),
- this,
- SLOT(contextDestroyed(const QGLContext *)));
-}
-
-QGLPainterPrivateCache::~QGLPainterPrivateCache()
-{
-}
-
-QGLPainterPrivate *QGLPainterPrivateCache::fromContext
- (const QGLContext *context)
-{
- QGLPainterPrivate *priv = cache.value(context, 0);
- if (priv)
- return priv;
- priv = new QGLPainterPrivate();
- priv->context = context;
- cache.insert(context, priv);
- return priv;
-}
-
-QGLPainterPrivateCache *QGLPainterPrivateCache::instance()
-{
- return painterPrivateCache();
-}
-
-void QGLPainterPrivateCache::contextDestroyed(const QGLContext *context)
-{
- QGLPainterPrivate *priv = cache.value(context, 0);
- if (priv) {
- priv->context = 0;
- cache.remove(context);
- if (!priv->ref.deref())
- delete priv;
- }
- emit destroyedContext(context);
-}
-
-/*!
- Constructs a new GL painter. Call begin() to attach the
- painter to a GL context.
-
- \sa begin()
-*/
-QGLPainter::QGLPainter()
- : d_ptr(0)
-{
-}
-
-/*!
- Constructs a new GL painter and attaches it to \a context.
- It is not necessary to call begin() after construction.
-
- \sa begin()
-*/
-QGLPainter::QGLPainter(const QGLContext *context)
- : d_ptr(0)
-{
- begin(context);
-}
-
-/*!
- Constructs a new GL painter and attaches it to the GL
- context associated with \a widget. It is not necessary to
- call begin() after construction.
-
- \sa begin(), isActive()
-*/
-QGLPainter::QGLPainter(QGLWidget *widget)
- : d_ptr(0)
-{
- begin(widget);
-}
-
-/*!
- Constructs a new GL painter and attaches it to the GL context associated
- with \a painter. It is assumed that \a painter is the currently
- active painter and that it is associated with the current GL context.
-
- If \a painter is not using an OpenGL paint engine, then isActive()
- will return false; true otherwise.
-
- This constructor is typically used when mixing regular Qt painting
- operations and GL painting operations on a widget that is being
- drawn using the OpenGL graphics system.
-
- \sa begin(), isActive()
-*/
-QGLPainter::QGLPainter(QPainter *painter)
- : d_ptr(0)
-{
- begin(painter);
-}
-
-/*!
- Constructs a new GL painter and attaches it to the GL context associated
- with \a surface.
-
- \sa begin(), isActive()
-*/
-QGLPainter::QGLPainter(QGLAbstractSurface *surface)
- : d_ptr(0)
-{
- begin(surface);
-}
-
-/*!
- Destroys this GL painter.
-*/
-QGLPainter::~QGLPainter()
-{
- end();
-}
-
-/*!
- Begins painting on QGLContext::currentContext(). Returns false
- if there is no GL context current.
-
- \sa end()
-*/
-bool QGLPainter::begin()
-{
- return begin(QGLContext::currentContext());
-}
-
-/*!
- Begins painting on \a context. If painting was already in progress,
- then this function will call end() first. The \a context will be
- made current if it is not already current.
-
- Returns true if painting can begin; false otherwise.
-
- All QGLPainter instances on a context share the same context state:
- matrices, the effect(), vertex attributes, etc. For example,
- calling ortho() on one QGLPainter instance for a context will
- alter the projectionMatrix() as seen by the other QGLPainter instances.
-
- \sa end(), isActive()
-*/
-bool QGLPainter::begin(const QGLContext *context)
-{
- if (!context)
- return false;
- end();
- return begin(context, QGLAbstractSurface::createSurfaceForContext(context));
-}
-
-/*!
- \internal
-*/
-bool QGLPainter::begin
- (const QGLContext *context, QGLAbstractSurface *surface,
- bool destroySurface)
-{
- // If we don't have a context specified, then use the one
- // that the surface just made current.
- if (!context)
- context = QGLContext::currentContext();
-
- // Find the QGLPainterPrivate for the context, or create a new one.
- d_ptr = painterPrivateCache()->fromContext(context);
- d_ptr->ref.ref();
- if (d_ptr->renderSequencer)
- {
- d_ptr->renderSequencer->reset();
- d_ptr->renderSequencer->setPainter(this);
- }
-
- // Activate the main surface for the context.
- QGLAbstractSurface *prevSurface;
- if (d_ptr->surfaceStack.isEmpty()) {
- prevSurface = 0;
- } else {
- // We are starting a nested begin()/end() scope, so switch
- // to the new main surface rather than activate from scratch.
- prevSurface = d_ptr->surfaceStack.last().surface;
- prevSurface->deactivate(surface);
- }
- if (!surface->activate(prevSurface)) {
- if (prevSurface)
- prevSurface->activate(surface);
- if (destroySurface)
- delete surface;
- if (!d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = 0;
- return false;
- }
-
- // Push a main surface descriptor onto the surface stack.
- QGLPainterSurfaceInfo psurf;
- psurf.surface = surface;
- psurf.destroySurface = destroySurface;
- psurf.mainSurface = true;
- d_ptr->surfaceStack.append(psurf);
-
- // Force the matrices to be updated the first time we use them.
- d_ptr->modelViewMatrix.setDirty(true);
- d_ptr->projectionMatrix.setDirty(true);
-
- // Initialize the QOpenGLFunctions parent class.
- initializeGLFunctions(context);
-
- // Determine if the OpenGL implementation is fixed-function or not.
- d_ptr->isFixedFunction = !hasOpenGLFeature(QOpenGLFunctions::Shaders);
- return true;
-}
-
-/*!
- Begins painting on the GL context associated with \a widget.
- Returns false if \a widget is null.
-
- \sa end()
-*/
-bool QGLPainter::begin(QGLWidget *widget)
-{
- if (!widget)
- return false;
- end();
- return begin(widget->context(), new QGLWidgetSurface(widget));
-}
-
-/*!
- Begins painting on the GL context associated with \a painter.
- Returns false if \a painter is not using an OpenGL paint engine.
- It is assumed that \a painter is the currently active painter
- and that it is associated with the current GL context.
-
- This function is typically used when mixing regular Qt painting
- operations and GL painting operations on a widget that is being
- drawn using the OpenGL graphics system.
-
- \sa end()
-*/
-bool QGLPainter::begin(QPainter *painter)
-{
- // Validate that the painting is OpenGL-based.
- if (!painter)
- return false;
- QPaintEngine *engine = painter->paintEngine();
- if (!engine)
- return false;
- if (engine->type() != QPaintEngine::OpenGL &&
- engine->type() != QPaintEngine::OpenGL2)
- return false;
-
- // Begin GL painting operations.
- return begin(0, new QGLPainterSurface(painter));
-}
-
-/*!
- Begins painting to \a surface. Returns false if \a surface is
- null or could not be activated.
-
- \sa end(), QGLAbstractSurface::activate()
-*/
-bool QGLPainter::begin(QGLAbstractSurface *surface)
-{
- if (!surface)
- return false;
- end();
- return begin(0, surface, false);
-}
-
-/*!
- Ends GL painting. Returns true if painting was ended successfully;
- false if this painter was not bound to a GL context.
-
- The GL context that was bound to this painter will not have
- QGLContext::doneCurrent() called on it. It is the responsibility
- of the caller to terminate context operations.
-
- The effect() will be left active in the GL context and will be
- assumed to still be active the next time begin() is called.
- If this assumption doesn't apply, then call disableEffect()
- to disable the effect before calling end().
-
- This function will pop all surfaces from the surface stack,
- and return currentSurface() to null (the default drawing surface).
-
- \sa begin(), isActive(), disableEffect()
-*/
-bool QGLPainter::end()
-{
- Q_D(QGLPainter);
- if (!d)
- return false;
-
- // Unbind the current vertex and index buffers.
- if (d->boundVertexBuffer) {
- QGLBuffer::release(QGLBuffer::VertexBuffer);
- d->boundVertexBuffer = 0;
- }
- if (d->boundIndexBuffer) {
- QGLBuffer::release(QGLBuffer::IndexBuffer);
- d->boundIndexBuffer = 0;
- }
-
- // Pop surfaces from the surface stack until we reach a
- // main surface. Then deactivate the main surface.
- int size = d->surfaceStack.size();
- while (size > 0) {
- --size;
- QGLPainterSurfaceInfo &surf = d->surfaceStack[size];
- if (surf.mainSurface) {
- if (size > 0) {
- // There are still other surfaces on the stack, probably
- // because we are within a nested begin()/end() scope.
- // Re-activate the next surface down in the outer scope.
- QGLPainterSurfaceInfo &nextSurf = d->surfaceStack[size - 1];
- surf.surface->switchTo(nextSurf.surface);
- } else {
- // Last surface on the stack, so deactivate it permanently.
- surf.surface->deactivate();
- }
- if (surf.destroySurface)
- delete surf.surface;
- break;
- } else if (size > 0) {
- surf.surface->deactivate(d->surfaceStack[size - 1].surface);
- }
- }
- d->surfaceStack.resize(size);
-
- // Force a viewport update if we are within a nested begin()/end().
- d->updates |= UpdateViewport;
-
- // Destroy the QGLPainterPrivate if this is the last reference.
- if (!d->ref.deref())
- delete d;
- d_ptr = 0;
- return true;
-}
-
-/*!
- Returns true if this painter is currently bound to a GL context;
- false otherwise.
-
- \sa begin(), end()
-*/
-bool QGLPainter::isActive() const
-{
- return (d_ptr != 0 && d_ptr->context != 0);
-}
-
-/*!
- Returns the GL context that is bound to this painter, or null
- if it is not currently bound.
-*/
-const QGLContext *QGLPainter::context() const
-{
- if (d_ptr)
- return d_ptr->context;
- else
- return 0;
-}
-
-/*!
- Returns true if the underlying OpenGL implementation is OpenGL 1.x
- or OpenGL/ES 1.x and only supports fixed-function OpenGL operations.
- Returns false if the underlying OpenGL implementation is using
- GLSL or GLSL/ES shaders.
-
- If this function returns false, then the built-in effects will
- use shaders and QGLPainter will not update the fixed-function
- matrices in the OpenGL context when update() is called.
- User-supplied effects will need to use shaders also or update
- the fixed-function matrices themselves or call updateFixedFunction().
-
- \sa update(), updateFixedFunction()
-*/
-bool QGLPainter::isFixedFunction() const
-{
-#if defined(QT_OPENGL_ES_2)
- return false;
-#else
- Q_D(const QGLPainter);
- if (d)
- return d->isFixedFunction;
- else
- return true;
-#endif
-}
-
-/*!
- Sets the \a color to use to clear the color buffer when \c{glClear()}
- is called.
-*/
-void QGLPainter::setClearColor(const QColor& color)
-{
- glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
-}
-
-/*!
- Sets the scissor \a rect for the current drawing surface
- to use when \c{GL_SCISSOR_TEST} is enabled. If \a rect is empty,
- then the scissor will be set to clip away all drawing.
-
- Note that \a rect is in Qt co-ordinates with the origin
- at the top-left of the drawing surface's viewport rectangle.
- If the currentSurface() is an instance of QGLSubsurface,
- then \a rect will be adjusted relative to the subsurface's position.
-
- \sa currentSurface(), QGLAbstractSurface::viewportGL()
-*/
-void QGLPainter::setScissor(const QRect& rect)
-{
- if (!rect.isEmpty()) {
- // Adjust the rectangle by the position of the surface viewport.
- QGLAbstractSurface *surface = currentSurface();
- QRect viewport = surface->viewportGL();
- QRect r(viewport.x() + rect.x(),
- viewport.y() + viewport.height() - (rect.y() + rect.height()),
- rect.width(), rect.height());
- if (!r.isEmpty())
- glScissor(r.x(), r.y(), r.width(), r.height());
- else
- glScissor(0, 0, 0, 0);
- } else {
- glScissor(0, 0, 0, 0);
- }
-}
-
-/*!
- Returns a reference to the projection matrix stack.
-
- It is recommended that setCamera() be used to set the projection
- matrix at the beginning of a scene rendering pass so that the
- eye position can be adjusted for stereo.
-
- \sa modelViewMatrix(), combinedMatrix(), setCamera()
-*/
-QMatrix4x4Stack& QGLPainter::projectionMatrix()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->projectionMatrix;
-}
-
-/*!
- Returns a reference to the modelview matrix stack.
-
- \sa projectionMatrix(), combinedMatrix(), normalMatrix(), setCamera()
- \sa worldMatrix()
-*/
-QMatrix4x4Stack& QGLPainter::modelViewMatrix()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->modelViewMatrix;
-}
-
-/*!
- \fn QMatrix4x4 QGLPainter::combinedMatrix() const
-
- Returns the result of multiplying the projectionMatrix()
- and the modelViewMatrix(). This combined matrix value is
- useful for setting uniform matrix values on shader programs.
-
- Calling this function is more efficient than calling
- projectionMatrix() and modelViewMatrix() separately and
- multiplying the return values.
-
- \sa projectionMatrix(), modelViewMatrix(), normalMatrix()
-*/
-QMatrix4x4 QGLPainter::combinedMatrix() const
-{
- const QGLPainterPrivate *d = d_func();
- if (!d)
- return QMatrix4x4();
- const QMatrix4x4StackPrivate *proj = d->projectionMatrix.d_func();
- const QMatrix4x4StackPrivate *mv = d->modelViewMatrix.d_func();
- return proj->matrix * mv->matrix;
-}
-
-// Inverting the eye transformation will often result in values like
-// 1.5e-15 in the world matrix. Clamp these to zero to make worldMatrix()
-// more stable when removing the eye component of the modelViewMatrix().
-static inline qreal qt_gl_stablize_value(qreal value)
-{
- return (qAbs(value) >= 0.00001f) ? value : 0.0f;
-}
-static inline QMatrix4x4 qt_gl_stablize_matrix(const QMatrix4x4 &m)
-{
- return QMatrix4x4(qt_gl_stablize_value(m(0, 0)),
- qt_gl_stablize_value(m(0, 1)),
- qt_gl_stablize_value(m(0, 2)),
- qt_gl_stablize_value(m(0, 3)),
- qt_gl_stablize_value(m(1, 0)),
- qt_gl_stablize_value(m(1, 1)),
- qt_gl_stablize_value(m(1, 2)),
- qt_gl_stablize_value(m(1, 3)),
- qt_gl_stablize_value(m(2, 0)),
- qt_gl_stablize_value(m(2, 1)),
- qt_gl_stablize_value(m(2, 2)),
- qt_gl_stablize_value(m(2, 3)),
- qt_gl_stablize_value(m(3, 0)),
- qt_gl_stablize_value(m(3, 1)),
- qt_gl_stablize_value(m(3, 2)),
- qt_gl_stablize_value(m(3, 3)));
-}
-
-/*!
- Returns the world matrix, which is the modelViewMatrix() without
- the eye transformation that was set in the previous call to
- setCamera().
-
- In the following example, the \c{world} variable will be set to the
- translation and scale component of the modelview transformation,
- without the "look at" component from the camera:
-
- \code
- painter.setCamera(camera);
- painter.modelViewMatrix().translate(0.0f, 5.0f, 0.0f);
- painter.modelViewMatrix().scale(1.5f);
- QMatrix4x4 world = painter.worldMatrix();
- \endcode
-
- Note: the world matrix is determined by multiplying the inverse of
- the camera's look at component with the current modelview matrix.
- Thus, the result may not be precisely the same as constructing a
- matrix from translate and scale operations starting with the identity.
-
- \sa modelViewMatrix(), setCamera()
-*/
-QMatrix4x4 QGLPainter::worldMatrix() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return qt_gl_stablize_matrix
- (d->inverseEyeMatrix * d->modelViewMatrix.top());
-}
-
-/*!
- \fn QMatrix3x3 QGLPainter::normalMatrix() const
-
- Returns the normal matrix corresponding to modelViewMatrix().
-
- The normal matrix is the transpose of the inverse of the top-left
- 3x3 part of the 4x4 modelview matrix. If the 3x3 sub-matrix is not
- invertible, this function returns the identity.
-
- \sa modelViewMatrix(), combinedMatrix()
-*/
-QMatrix3x3 QGLPainter::normalMatrix() const
-{
- const QGLPainterPrivate *d = d_func();
- if (!d)
- return QMatrix3x3();
- const QMatrix4x4StackPrivate *mv = d->modelViewMatrix.d_func();
- return mv->matrix.normalMatrix();
-}
-
-/*!
- Returns the camera eye that is currently being used for stereo
- rendering. The default is QGL::NoEye.
-
- The eye is used to adjust the camera position by a small amount
- when setCamera() is called.
-
- \sa setEye(), setCamera()
-*/
-QGL::Eye QGLPainter::eye() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->eye;
-}
-
-/*!
- Sets the camera \a eye that is currently being used for stereo
- rendering.
-
- The \a eye is used to adjust the camera position by a small amount
- when setCamera() is called.
-
- \sa eye(), setCamera()
-*/
-void QGLPainter::setEye(QGL::Eye eye)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->eye = eye;
-}
-
-/*!
- Sets the modelViewMatrix() and projectionMatrix() to the view
- defined by \a camera. If eye() is not QGL::NoEye, then the view
- will be adjusted for the camera's eye separation.
-
- This function is typically called at the beginning of a scene rendering
- pass to initialize the modelview and projection matrices.
-
- \sa eye(), modelViewMatrix(), projectionMatrix(), worldMatrix()
-*/
-void QGLPainter::setCamera(const QGLCamera *camera)
-{
- Q_ASSERT(camera);
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- QMatrix4x4 lookAt = camera->modelViewMatrix(d->eye);
- d->modelViewMatrix = lookAt;
- d->projectionMatrix = camera->projectionMatrix(aspectRatio());
- d->inverseEyeMatrix = lookAt.inverted();
-}
-
-/*!
- Returns true if \a point is outside the current viewing volume.
- This is used to perform object culling checks.
-*/
-bool QGLPainter::isCullable(const QVector3D& point) const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- QVector3D projected = d->modelViewMatrix * point;
- projected = d->projectionMatrix * projected;
- return !d->viewingCube.contains(projected);
-}
-
-static inline uint outcode(const QVector4D &v)
-{
- // For a discussion of outcodes see pg 388 Dunn & Parberry.
- // For why you can't just test if the point is in a bounding box
- // consider the case where a view frustum with view-size 1.5 x 1.5
- // is tested against a 2x2 box which encloses the near-plane, while
- // all the points in the box are outside the frustum.
- // TODO: optimise this with assembler - according to D&P this can
- // be done in one line of assembler on some platforms
- uint code = 0;
- if (v.x() < -v.w()) code |= 0x01;
- if (v.x() > v.w()) code |= 0x02;
- if (v.y() < -v.w()) code |= 0x04;
- if (v.y() > v.w()) code |= 0x08;
- if (v.z() < -v.w()) code |= 0x10;
- if (v.z() > v.w()) code |= 0x20;
- return code;
-}
-
-/*!
- Returns true if \a box is completely outside the current viewing volume.
- This is used to perform object culling checks.
-*/
-bool QGLPainter::isCullable(const QBox3D& box) const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- // This function uses the technique of view frustum culling known as
- // clip space testing. Since the normal QVector3D representation
- // of the points throws away the w value needed, we convert the box
- // into a set of 8 points represented as QVector4D's and then apply
- // the test. The test is to transform the points into clip space
- // by applying the MV and Proj matrices, then test to see if the 4D
- // points are outside the clip space by testing x, y & z against w.
- QArray<QVector4D> box4d;
- QVector3D n = box.minimum();
- QVector3D x = box.maximum();
- box4d.append(QVector4D(n.x(), n.y(), x.z(), 1), QVector4D(x.x(), n.y(), x.z(), 1),
- QVector4D(x.x(), x.y(), x.z(), 1), QVector4D(n.x(), x.y(), x.z(), 1));
- box4d.append(QVector4D(n.x(), n.y(), n.z(), 1), QVector4D(x.x(), n.y(), n.z(), 1),
- QVector4D(x.x(), x.y(), n.z(), 1), QVector4D(n.x(), x.y(), n.z(), 1));
- QMatrix4x4 mvp = d->projectionMatrix.top() * d->modelViewMatrix.top();
- for (int i = 0; i < box4d.size(); ++i)
- {
- box4d[i] = mvp * box4d.at(i);
- }
- // if the logical AND of all the outcodes is non-zero then the BB is
- // definitely outside the view frustum.
- uint out = 0xff;
- for (int i = 0; i < box4d.size(); ++i)
- {
- out = out & outcode(box4d.at(i));
- }
- return out;
-}
-
-/*!
- Returns the current render order sequencer.
-
- \sa QGLRenderSequencer
-*/
-QGLRenderSequencer *QGLPainter::renderSequencer()
-{
- Q_D(QGLPainter);
- if (!d->renderSequencer)
- d->renderSequencer = new QGLRenderSequencer(this);
- return d->renderSequencer;
-}
-
-/*!
- Returns the aspect ratio of the viewport for adjusting projection
- transformations.
-*/
-qreal QGLPainter::aspectRatio() const
-{
- return currentSurface()->aspectRatio();
-}
-
-/*!
- Returns the current effect that is in use, which is userEffect()
- if it is not null, or the effect object associated with
- standardEffect() otherwise.
-
- If isPicking() is true, then this will return the effect object
- that is being used to generate pick colors.
-
- \sa userEffect(), standardEffect(), isPicking()
-*/
-QGLAbstractEffect *QGLPainter::effect() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->ensureEffect(const_cast<QGLPainter *>(this));
- return d->effect;
-}
-
-/*!
- Returns the user-defined effect that is being used for drawing
- operations, or null if standardEffect() is in use.
-
- \sa setUserEffect(), standardEffect(), effect()
-*/
-QGLAbstractEffect *QGLPainter::userEffect() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->userEffect;
-}
-
-/*!
- Sets a user-defined \a effect to use for drawing operations
- in the current GL context. If \a effect is null, this will
- disable user-defined effects and return to using standardEffect().
-
- \sa effect(), draw(), setStandardEffect()
-*/
-void QGLPainter::setUserEffect(QGLAbstractEffect *effect)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->userEffect == effect)
- return;
- if (d->effect)
- d->effect->setActive(this, false);
- d->userEffect = effect;
- if (effect && (!d->pick || !d->pick->isPicking)) {
- d->effect = effect;
- d->effect->setActive(this, true);
- d->updates = UpdateAll;
- } else {
- // Revert to the effect associated with standardEffect().
- d->effect = 0;
- d->ensureEffect(this);
- }
-}
-
-/*!
- Returns the standard effect to use for rendering fragments in
- the current GL context when userEffect() is null.
-
- \sa setStandardEffect(), userEffect()
-*/
-QGL::StandardEffect QGLPainter::standardEffect() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->standardEffect;
-}
-
-/*!
- Sets a standard \a effect to use for rendering fragments
- in the current GL context. This will also set userEffect()
- to null. If \a effect is an invalid value, then the behavior
- of QGL::FlatColor will be used instead.
-
- \sa standardEffect(), setUserEffect()
-*/
-void QGLPainter::setStandardEffect(QGL::StandardEffect effect)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->standardEffect == effect && d->effect && d->userEffect == 0)
- return;
- if (d->effect)
- d->effect->setActive(this, false);
- d->standardEffect = effect;
- d->userEffect = 0;
- d->effect = 0;
- d->ensureEffect(this);
-}
-
-/*!
- Disables the current effect and sets userEffect() to null.
- Unlike setUserEffect() this not activate the standardEffect()
- until the next time effect() is called.
-
- This function can be used to disable all effect-based drawing
- operations prior to performing raw GL calls. The next time
- effect() is called on this QGLPainter, the standardEffect()
- will be reactivated. An effect can also be reactivated by
- calling setUserEffect() or setStandardEffect().
-
- \sa userEffect(), standardEffect()
-*/
-void QGLPainter::disableEffect()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->effect)
- d->effect->setActive(this, false);
- d->userEffect = 0;
- d->effect = 0;
-}
-
-/*!
- Returns the cached shader program associated with \a name; or null
- if \a name is not currently associated with a shader program.
-
- \sa setCachedProgram()
-*/
-QGLShaderProgram *QGLPainter::cachedProgram(const QString& name) const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->cachedPrograms.value(name, 0);
-}
-
-/*!
- Sets the cached shader \a program associated with \a name.
-
- Effect objects can use this function to store pre-compiled
- and pre-linked shader programs in the painter for future
- use by the same effect. The \a program will be destroyed
- when context() is destroyed.
-
- If \a program is null, then the program associated with \a name
- will be destroyed. If \a name is already present as a cached
- program, then it will be replaced with \a program.
-
- Names that start with "\c{qt.}" are reserved for use by Qt's
- internal effects.
-
- \sa cachedProgram()
-*/
-void QGLPainter::setCachedProgram
- (const QString& name, QGLShaderProgram *program)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- QGLShaderProgram *current = d->cachedPrograms.value(name, 0);
- if (current != program) {
- if (program)
- d->cachedPrograms[name] = program;
- else
- d->cachedPrograms.remove(name);
- delete current;
- }
-}
-
-void QGLPainterPrivate::createEffect(QGLPainter *painter)
-{
- if (userEffect) {
- if (!pick || !pick->isPicking) {
- effect = userEffect;
- effect->setActive(painter, true);
- updates = QGLPainter::UpdateAll;
- return;
- }
- if (userEffect->supportsPicking()) {
- effect = userEffect;
- effect->setActive(painter, true);
- updates = QGLPainter::UpdateAll;
- return;
- }
- effect = pick->defaultPickEffect;
- effect->setActive(painter, true);
- updates = QGLPainter::UpdateAll;
- return;
- }
- if (uint(standardEffect) >= QGL_MAX_STD_EFFECTS)
- effect = stdeffects[int(QGL::FlatColor)];
- else
- effect = stdeffects[int(standardEffect)];
- if (!effect) {
- switch (standardEffect) {
- case QGL::FlatColor: default:
- effect = new QGLFlatColorEffect();
- break;
- case QGL::FlatPerVertexColor:
- effect = new QGLPerVertexColorEffect();
- break;
- case QGL::FlatReplaceTexture2D:
- effect = new QGLFlatTextureEffect();
- break;
- case QGL::FlatDecalTexture2D:
- effect = new QGLFlatDecalTextureEffect();
- break;
- case QGL::LitMaterial:
- effect = new QGLLitMaterialEffect();
- break;
- case QGL::LitDecalTexture2D:
- effect = new QGLLitDecalTextureEffect();
- break;
- case QGL::LitModulateTexture2D:
- effect = new QGLLitModulateTextureEffect();
- break;
- }
- if (uint(standardEffect) >= QGL_MAX_STD_EFFECTS)
- stdeffects[int(QGL::FlatColor)] = effect;
- else
- stdeffects[int(standardEffect)] = effect;
- }
- if (!pick || !pick->isPicking || effect->supportsPicking()) {
- effect->setActive(painter, true);
- } else {
- effect = pick->defaultPickEffect;
- effect->setActive(painter, true);
- }
- updates = QGLPainter::UpdateAll;
-}
-
-/*!
- Returns the last color that was set with setColor(). The default
- value is (1, 1, 1, 1).
-
- \sa setColor()
-*/
-QColor QGLPainter::color() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->color;
-}
-
-/*!
- Sets the default fragment \a color for effects associated
- with this painter. This function does not apply the color
- to the effect until update() is called.
-
- \sa color(), update()
-*/
-void QGLPainter::setColor(const QColor& color)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->color = color;
- d->updates |= UpdateColor;
-}
-
-static void qt_gl_setVertexAttribute(QGL::VertexAttribute attribute, const QGLAttributeValue& value)
-{
-#if !defined(QT_OPENGL_ES_2)
- switch (attribute) {
- case QGL::Position:
- glVertexPointer(value.tupleSize(), value.type(),
- value.stride(), value.data());
- break;
-
- case QGL::Normal:
- if (value.tupleSize() == 3)
- glNormalPointer(value.type(), value.stride(), value.data());
- break;
-
- case QGL::Color:
- glColorPointer(value.tupleSize(), value.type(),
- value.stride(), value.data());
- break;
-
-#ifdef GL_TEXTURE_COORD_ARRAY
- case QGL::TextureCoord0:
- case QGL::TextureCoord1:
- case QGL::TextureCoord2:
- {
- int unit = (int)(attribute - QGL::TextureCoord0);
- qt_gl_ClientActiveTexture(GL_TEXTURE0 + unit);
- glTexCoordPointer(value.tupleSize(), value.type(),
- value.stride(), value.data());
- if (unit != 0) // Stay on unit 0 between requests.
- qt_gl_ClientActiveTexture(GL_TEXTURE0);
- }
- break;
-#endif
-
- default: break;
- }
-#else
- Q_UNUSED(attribute);
- Q_UNUSED(value);
-#endif
-}
-
-/*!
- Returns the set of vertex attributes that have been set on the
- painter state by setVertexAttribute() and setVertexBundle()
- since the last call to clearAttributes().
-
- The most common use for this function is to determine if specific
- attributes have been supplied on the painter so as to adjust the
- current drawing effect accordingly. The following example will
- use a lit texture effect if texture co-ordinates were provided
- in the vertex bundle, or a simple lit material effect if
- texture co-ordinates were not provided:
-
- \code
- painter.clearAttributes();
- painter.setVertexBundle(bundle);
- if (painter.attributes().contains(QGL::TextureCoord0))
- painter.setStandardEffect(QGL::LitModulateTexture2D);
- else
- painter.setStandardEffect(QGL::LitMaterial);
- \endcode
-
- It is important to clear the attributes before setting the vertex
- bundle, so that attributes from a previous bundle will not leak
- through. Multiple vertex bundles may be supplied if they contain
- different parts of the same logical piece of geometry.
-
- \sa clearAttributes(), setVertexBundle()
-*/
-QGLAttributeSet QGLPainter::attributes() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->attributeSet;
-}
-
-/*!
- Clears the set of vertex attributes that have been set on the
- painter state by setVertexAttribute() and setVertexBundle().
- See the documentation for attributes() for more information.
-
- \sa attributes()
-*/
-void QGLPainter::clearAttributes()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->attributeSet.clear();
-}
-
-/*!
- Sets a vertex \a attribute on the current GL context to \a value.
-
- The vertex attribute is bound to the GL state on the index
- corresponding to \a attribute. For example, QGL::Position
- will be bound to index 0, QGL::TextureCoord0 will be bound
- to index 3, etc.
-
- Vertex attributes are independent of the effect() and can be
- bound once and then used with multiple effects.
-
- If this is the first attribute in a new piece of geometry,
- it is recommended that clearAttributes() be called before this
- function. This will inform QGLPainter that a new piece of geometry
- is being provided and that the previous geometry is now invalid.
- See the documentation for attributes() for more information.
-
- \sa setVertexBundle(), draw(), clearAttributes(), attributes()
-*/
-void QGLPainter::setVertexAttribute
- (QGL::VertexAttribute attribute, const QGLAttributeValue& value)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->ensureEffect(this);
- if (d->boundVertexBuffer) {
- QGLBuffer::release(QGLBuffer::VertexBuffer);
- d->boundVertexBuffer = 0;
- }
- if (d->isFixedFunction) {
- qt_gl_setVertexAttribute(attribute, value);
- } else {
- glVertexAttribPointer(GLuint(attribute), value.tupleSize(),
- value.type(), GL_TRUE,
- value.stride(), value.data());
- }
- d->attributeSet.insert(attribute);
-}
-
-/*!
- Sets the vertex attributes on the current GL context that are
- stored in \a buffer.
-
- The vertex attributes are bound to the GL state on the indexes
- that are specified within \a buffer; QGL::Position will be
- bound to index 0, QGL::TextureCoord0 will be bound to index 3, etc.
-
- Vertex attributes are independent of the effect() and can be
- bound once and then used with multiple effects.
-
- It is recommended that clearAttributes() be called before this
- function to inform QGLPainter that a new piece of geometry is
- being provided and that the previous geometry is now invalid.
- See the documentation for attributes() for more information.
-
- \sa setVertexAttribute(), draw(), clearAttributes(), attributes()
-*/
-void QGLPainter::setVertexBundle(const QGLVertexBundle& buffer)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->ensureEffect(this);
- QGLVertexBundlePrivate *bd = const_cast<QGLVertexBundlePrivate *>(buffer.d_func());
- if (bd->buffer.isCreated()) {
- GLuint id = bd->buffer.bufferId();
- if (id != d->boundVertexBuffer) {
- bd->buffer.bind();
- d->boundVertexBuffer = id;
- }
- } else if (d->boundVertexBuffer) {
- QGLBuffer::release(QGLBuffer::VertexBuffer);
- d->boundVertexBuffer = 0;
- }
- for (int index = 0; index < bd->attributes.size(); ++index) {
- QGLVertexBundleAttribute *attr = bd->attributes[index];
- if (d->isFixedFunction) {
- qt_gl_setVertexAttribute(attr->attribute, attr->value);
- } else {
- glVertexAttribPointer(GLuint(attr->attribute),
- attr->value.tupleSize(),
- attr->value.type(), GL_TRUE,
- attr->value.stride(), attr->value.data());
- }
- }
- d->attributeSet.unite(buffer.attributes());
-}
-
-/*!
- Updates the projection matrix, modelview matrix, and lighting
- conditions in the currently active effect() object by calling
- QGLAbstractEffect::update(). Also updates \c{glViewport()}
- to cover the currentSurface() if necessary.
-
- Normally this function is called automatically by draw().
- However, if the user wishes to use raw GL functions to draw fragments,
- it will be necessary to explicitly call this function to ensure that
- the matrix state and lighting conditions have been set on the
- active effect().
-
- Note that this function informs the effect that an update is needed.
- It does not change the GL state itself, except for \c{glViewport()}.
- In particular, the modelview and projection matrices in the
- fixed-function pipeline are not changed unless the effect or
- application calls updateFixedFunction().
-
- \sa setUserEffect(), projectionMatrix(), modelViewMatrix()
- \sa draw(), updateFixedFunction()
-*/
-void QGLPainter::update()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->ensureEffect(this);
- QGLPainter::Updates updates = d->updates;
- d->updates = 0;
- if (d->modelViewMatrix.isDirty()) {
- updates |= UpdateModelViewMatrix;
- d->modelViewMatrix.setDirty(false);
- }
- if (d->projectionMatrix.isDirty()) {
- updates |= UpdateProjectionMatrix;
- d->projectionMatrix.setDirty(false);
- }
- if ((updates & UpdateViewport) != 0) {
- QRect viewport = currentSurface()->viewportGL();
- glViewport(viewport.x(), viewport.y(),
- viewport.width(), viewport.height());
- }
- if (updates != 0)
- d->effect->update(this, updates);
-}
-
-#if !defined(QT_OPENGL_ES_2)
-
-static void setLight(int light, const QGLLightParameters *parameters,
- const QMatrix4x4& transform)
-{
- GLfloat params[4];
-
- QColor color = parameters->ambientColor();
- params[0] = color.redF();
- params[1] = color.greenF();
- params[2] = color.blueF();
- params[3] = color.alphaF();
- glLightfv(light, GL_AMBIENT, params);
-
- color = parameters->diffuseColor();
- params[0] = color.redF();
- params[1] = color.greenF();
- params[2] = color.blueF();
- params[3] = color.alphaF();
- glLightfv(light, GL_DIFFUSE, params);
-
- color = parameters->specularColor();
- params[0] = color.redF();
- params[1] = color.greenF();
- params[2] = color.blueF();
- params[3] = color.alphaF();
- glLightfv(light, GL_SPECULAR, params);
-
- QVector4D vector = parameters->eyePosition(transform);
- params[0] = vector.x();
- params[1] = vector.y();
- params[2] = vector.z();
- params[3] = vector.w();
- glLightfv(light, GL_POSITION, params);
-
- QVector3D spotDirection = parameters->eyeSpotDirection(transform);
- params[0] = spotDirection.x();
- params[1] = spotDirection.y();
- params[2] = spotDirection.z();
- glLightfv(light, GL_SPOT_DIRECTION, params);
-
- params[0] = parameters->spotExponent();
- glLightfv(light, GL_SPOT_EXPONENT, params);
-
- params[0] = parameters->spotAngle();
- glLightfv(light, GL_SPOT_CUTOFF, params);
-
- params[0] = parameters->constantAttenuation();
- glLightfv(light, GL_CONSTANT_ATTENUATION, params);
-
- params[0] = parameters->linearAttenuation();
- glLightfv(light, GL_LINEAR_ATTENUATION, params);
-
- params[0] = parameters->quadraticAttenuation();
- glLightfv(light, GL_QUADRATIC_ATTENUATION, params);
-}
-
-static void setMaterial(int face, const QGLMaterial *parameters)
-{
- GLfloat params[17];
-
- QColor mcolor = parameters->ambientColor();
- params[0] = mcolor.redF();
- params[1] = mcolor.greenF();
- params[2] = mcolor.blueF();
- params[3] = mcolor.alphaF();
-
- mcolor = parameters->diffuseColor();
- params[4] = mcolor.redF();
- params[5] = mcolor.greenF();
- params[6] = mcolor.blueF();
- params[7] = mcolor.alphaF();
-
- mcolor = parameters->specularColor();
- params[8] = mcolor.redF();
- params[9] = mcolor.greenF();
- params[10] = mcolor.blueF();
- params[11] = mcolor.alphaF();
-
- mcolor = parameters->emittedLight();
- params[12] = mcolor.redF();
- params[13] = mcolor.greenF();
- params[14] = mcolor.blueF();
- params[15] = mcolor.alphaF();
-
- params[16] = parameters->shininess();
-
- glMaterialfv(face, GL_AMBIENT, params);
- glMaterialfv(face, GL_DIFFUSE, params + 4);
- glMaterialfv(face, GL_SPECULAR, params + 8);
- glMaterialfv(face, GL_EMISSION, params + 12);
- glMaterialfv(face, GL_SHININESS, params + 16);
-}
-
-#endif // !QT_OPENGL_ES_2
-
-/*!
- Updates the fixed-function pipeline with the current painting
- state according to the flags in \a updates.
-
- This function is intended for use by effects in their
- QGLAbstractEffect::update() override if they are using the
- fixed-function pipeline. It can also be used by user
- applications if they need the QGLPainter state to be
- set in the fixed-function pipeline.
-
- If the OpenGL implementation does not have a fixed-function
- pipeline, e.g. OpenGL/ES 2.0, this function does nothing.
-
- \sa update()
-*/
-void QGLPainter::updateFixedFunction(QGLPainter::Updates updates)
-{
-#if defined(QT_OPENGL_ES_2)
- Q_UNUSED(updates);
-#else
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if ((updates & QGLPainter::UpdateColor) != 0) {
- QColor color;
- if (isPicking())
- color = pickColor();
- else
- color = this->color();
- glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
- }
- if ((updates & QGLPainter::UpdateModelViewMatrix) != 0) {
- const QMatrix4x4 &matrix = d->modelViewMatrix.top();
- glMatrixMode(GL_MODELVIEW);
- if (sizeof(qreal) == sizeof(GLfloat)) {
- glLoadMatrixf(reinterpret_cast<const GLfloat *>
- (matrix.constData()));
- } else {
- GLfloat mat[16];
- const qreal *m = matrix.constData();
- for (int index = 0; index < 16; ++index)
- mat[index] = m[index];
- glLoadMatrixf(mat);
- }
- }
- if ((updates & QGLPainter::UpdateProjectionMatrix) != 0) {
- const QMatrix4x4 &matrix = d->projectionMatrix.top();
- glMatrixMode(GL_PROJECTION);
- if (sizeof(qreal) == sizeof(GLfloat)) {
- glLoadMatrixf(reinterpret_cast<const GLfloat *>
- (matrix.constData()));
- } else {
- GLfloat mat[16];
- const qreal *m = matrix.constData();
- for (int index = 0; index < 16; ++index)
- mat[index] = m[index];
- glLoadMatrixf(mat);
- }
- }
- if ((updates & QGLPainter::UpdateLights) != 0) {
- // Save the current modelview matrix and load the identity.
- // We need to apply the light in the modelview transformation
- // that was active when the light was specified.
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Enable the main light.
- const QGLLightParameters *params = mainLight();
- setLight(GL_LIGHT0, params, mainLightTransform());
-
- // Restore the previous modelview transformation.
- glPopMatrix();
-
- // Set up the light model parameters if at least one light is enabled.
- const QGLLightModel *lightModel = this->lightModel();
- GLfloat values[4];
-#ifdef GL_LIGHT_MODEL_TWO_SIDE
- if (lightModel->model() == QGLLightModel::TwoSided)
- values[0] = 1.0f;
- else
- values[0] = 0.0f;
- glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, values);
-#endif
-#ifdef GL_LIGHT_MODEL_COLOR_CONTROL
- if (lightModel->colorControl() == QGLLightModel::SeparateSpecularColor)
- values[0] = GL_SEPARATE_SPECULAR_COLOR;
- else
- values[0] = GL_SINGLE_COLOR;
- glLightModelfv(GL_LIGHT_MODEL_COLOR_CONTROL, values);
-#endif
-#ifdef GL_LIGHT_MODEL_LOCAL_VIEWER
- if (lightModel->viewerPosition() == QGLLightModel::LocalViewer)
- values[0] = 1.0f;
- else
- values[0] = 0.0f;
- glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, values);
-#endif
-#ifdef GL_LIGHT_MODEL_AMBIENT
- QColor color = lightModel->ambientSceneColor();
- values[0] = color.redF();
- values[1] = color.blueF();
- values[2] = color.greenF();
- values[3] = color.alphaF();
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, values);
-#endif
- }
- if ((updates & QGLPainter::UpdateMaterials) != 0) {
- const QGLMaterial *frontMaterial = faceMaterial(QGL::FrontFaces);
- const QGLMaterial *backMaterial = faceMaterial(QGL::BackFaces);
- if (frontMaterial == backMaterial) {
- setMaterial(GL_FRONT_AND_BACK, frontMaterial);
- } else {
- setMaterial(GL_FRONT, frontMaterial);
- setMaterial(GL_BACK, backMaterial);
- }
- }
-#endif
-}
-
-/*!
- Draws primitives using \a count vertices from the arrays specified
- by setVertexAttribute(). The type of primitive to draw is specified
- by \a mode.
-
- This operation will consume \a count values from the
- enabled arrays, starting at \a index.
-
- \sa update()
-*/
-void QGLPainter::draw(QGL::DrawingMode mode, int count, int index)
-{
- update();
- glDrawArrays((GLenum)mode, index, count);
-}
-
-/*!
- \overload
-
- Draws primitives using vertices from the arrays specified by
- setVertexAttribute(). The type of primitive to draw is
- specified by \a mode.
-
- This operation will consume \a count elements of \a indices,
- which are used to index into the enabled arrays.
-
- \sa update()
-*/
-void QGLPainter::draw(QGL::DrawingMode mode, const ushort *indices, int count)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- update();
- if (d->boundIndexBuffer) {
- QGLBuffer::release(QGLBuffer::IndexBuffer);
- d->boundIndexBuffer = 0;
- }
- glDrawElements(GLenum(mode), count, GL_UNSIGNED_SHORT, indices);
-}
-
-/*!
- Pushes \a surface onto the surface stack and makes it the current
- drawing surface for context(). If \a surface is null, then the
- current drawing surface will be set to the main surface (e.g. the window).
-
- Note: the \a surface object must remain valid until popped from
- the stack or end() is called. All surfaces are popped from
- the stack by end().
-
- The UpdateViewport flag will be set to indicate that the
- \c{glViewport()} should be adjusted to the extents of \a surface
- when update() is next called.
-
- \sa popSurface(), currentSurface(), setSurface()
- \sa QGLAbstractSurface::activate()
-*/
-void QGLPainter::pushSurface(QGLAbstractSurface *surface)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- Q_ASSERT(surface);
- if (!surface) {
- // Find the most recent main surface for this painter.
- int size = d->surfaceStack.size();
- while (size > 0 && !d->surfaceStack[size - 1].mainSurface)
- --size;
- if (!size)
- return; // Shouldn't happen, but be safe anyway.
- surface = d->surfaceStack[size - 1].surface;
- }
- Q_ASSERT(!d->surfaceStack.isEmpty()); // Should have a main surface.
- QGLAbstractSurface *current = d->surfaceStack.top().surface;
- QGLPainterSurfaceInfo psurf;
- psurf.surface = surface;
- psurf.destroySurface = false;
- psurf.mainSurface = false;
- d->surfaceStack.append(psurf);
- current->switchTo(surface);
- d->updates |= UpdateViewport;
-}
-
-/*!
- Pops the top-most drawing surface from the surface stack
- and returns it. The next object on the stack will be made
- the current drawing surface for context(). Returns null if the
- surface stack is already at the main surface (e.g. the window).
-
- The UpdateViewport flag will be set to indicate that the
- \c{glViewport()} should be adjusted to the new surface extents
- when update() is next called.
-
- \sa pushSurface(), currentSurface(), setSurface()
-*/
-QGLAbstractSurface *QGLPainter::popSurface()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- Q_ASSERT(!d->surfaceStack.isEmpty()); // Should have a main surface.
- QGLPainterSurfaceInfo &surf = d->surfaceStack.top();
- if (surf.mainSurface)
- return 0;
- QGLAbstractSurface *surface = surf.surface;
- d->surfaceStack.pop();
- Q_ASSERT(!d->surfaceStack.isEmpty()); // Should have a main surface.
- QGLAbstractSurface *nextSurface = d->surfaceStack.top().surface;
- surface->switchTo(nextSurface);
- d->updates |= UpdateViewport;
- return surface;
-}
-
-/*!
- Sets the top-most drawing surface on the surface stack to \a surface
- and activate it.
-
- Note: if the top-most drawing surface is the main surface specified
- during begin(), then this function will perform a pushSurface()
- instead. Typically this function is used to replace the last
- surface that was pushed onto the stack and avoid doing popSurface()
- followed by pushSurface(). The main surface cannot be replaced
- in this manner.
-
- The UpdateViewport flag will be set to indicate that the
- \c{glViewport()} should be adjusted to the extents of \a surface
- when update() is next called.
-
- \sa pushSurface(), popSurface(), currentSurface()
-*/
-void QGLPainter::setSurface(QGLAbstractSurface *surface)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- Q_ASSERT(surface);
- Q_ASSERT(!d->surfaceStack.isEmpty()); // Should have a main surface.
- QGLPainterSurfaceInfo &surf = d->surfaceStack.top();
- if (surf.mainSurface) {
- pushSurface(surface);
- return;
- }
- QGLAbstractSurface *oldSurface = surf.surface;
- surf.surface = surface;
- oldSurface->switchTo(surface);
- d->updates |= UpdateViewport;
-}
-
-/*!
- Returns the current drawing surface.
-
- \sa pushSurface(), popSurface(), setSurface()
-*/
-QGLAbstractSurface *QGLPainter::currentSurface() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- Q_ASSERT(!d->surfaceStack.isEmpty()); // Should have a main surface.
- return d->surfaceStack.top().surface;
-}
-
-/*!
- Returns the current lighting model.
-
- \sa setLightModel()
-*/
-const QGLLightModel *QGLPainter::lightModel() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (!d->lightModel) {
- if (!d->defaultLightModel)
- d->defaultLightModel = new QGLLightModel();
- d->lightModel = d->defaultLightModel;
- }
- return d->lightModel;
-}
-
-/*!
- Sets the current lighting model to \a value. If \a value is
- null, then the default lighting model parameters will be used.
-
- The light settings in the GL server will not be changed until
- update() is called.
-
- \sa lightModel()
-*/
-void QGLPainter::setLightModel(const QGLLightModel *value)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- d->lightModel = value;
- d->updates |= QGLPainter::UpdateLights;
-}
-
-/*!
- Returns the parameters for the main light in the scene.
-
- The light parameters are specified in world co-ordinates at
- the point when setMainLight() was called. The mainLightTransform()
- must be applied to obtain eye co-ordinates.
-
- This function is a convenience that returns the light with
- identifier 0. If light 0 is not currently enabled, then a
- default light is added to the painter with an identity
- transform and then returned as the main light.
-
- \sa setMainLight(), mainLightTransform(), addLight()
-*/
-const QGLLightParameters *QGLPainter::mainLight() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->lights.isEmpty()) {
- if (!d->defaultLight)
- d->defaultLight = new QGLLightParameters();
- d->lights.append(d->defaultLight);
- d->lightTransforms.append(QMatrix4x4());
- } else if (!d->lights[0]) {
- if (!d->defaultLight)
- d->defaultLight = new QGLLightParameters();
- d->lights[0] = d->defaultLight;
- d->lightTransforms[0] = QMatrix4x4();
- }
- return d->lights[0];
-}
-
-/*!
- Sets the \a parameters for the main light in the scene.
- The mainLightTransform() is set to the current modelViewMatrix().
-
- Light parameters are stored in world co-ordinates, not eye co-ordinates.
- The mainLightTransform() specifies the transformation to apply to
- convert the world co-ordinates into eye co-ordinates when the light
- is used.
-
- Note: the \a parameters may be ignored by effect() if it
- has some other way to determine the lighting conditions.
-
- The light settings in the GL server will not be changed until
- update() is called.
-
- This function is a convenience that sets the light with
- identifier 0. If \a parameters is null, then light 0
- will be removed.
-
- \sa mainLight(), mainLightTransform(), addLight()
-*/
-void QGLPainter::setMainLight(const QGLLightParameters *parameters)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->lights.isEmpty()) {
- if (parameters) {
- d->lights.append(parameters);
- d->lightTransforms.append(modelViewMatrix());
- d->updates |= QGLPainter::UpdateLights;
- }
- } else if (parameters) {
- d->lights[0] = parameters;
- d->lightTransforms[0] = modelViewMatrix();
- d->updates |= QGLPainter::UpdateLights;
- } else {
- removeLight(0);
- }
-}
-
-/*!
- Sets the \a parameters for the main light in the scene, and set
- mainLightTransform() to \a transform.
-
- Light parameters are stored in world co-ordinates, not eye co-ordinates.
- The \a transform specifies the transformation to apply to convert the
- world co-ordinates into eye co-ordinates when the light is used.
-
- Note: the \a parameters may be ignored by effect() if it
- has some other way to determine the lighting conditions.
-
- The light settings in the GL server will not be changed until
- update() is called.
-
- This function is a convenience that sets the light with
- identifier 0. If \a parameters is null, then light 0
- will be removed.
-
- \sa mainLight(), mainLightTransform()
-*/
-void QGLPainter::setMainLight
- (const QGLLightParameters *parameters, const QMatrix4x4& transform)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->lights.isEmpty()) {
- if (parameters) {
- d->lights.append(parameters);
- d->lightTransforms.append(transform);
- d->updates |= QGLPainter::UpdateLights;
- }
- } else if (parameters) {
- d->lights[0] = parameters;
- d->lightTransforms[0] = transform;
- d->updates |= QGLPainter::UpdateLights;
- } else {
- removeLight(0);
- }
-}
-
-/*!
- Returns the modelview transformation matrix for the main light that
- was set at the time setMainLight() was called.
-
- The light transform may be used by later painting operations to
- convert the light from world co-ordinates into eye co-ordinates.
- The eye transformation is set when the light is specified.
-
- This function is a convenience that returns the tranform for the
- light with identifier 0. If light 0 is not enabled, then the
- function returns the identity matrix.
-
- \sa mainLight(), setMainLight(), addLight()
-*/
-QMatrix4x4 QGLPainter::mainLightTransform() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (!d->lights.isEmpty() && d->lights[0])
- return d->lightTransforms[0];
- else
- return QMatrix4x4();
-}
-
-/*!
- Adds a light to this painter, with the specified \a parameters.
- The lightTransform() for the light is set to the current
- modelViewMatrix(). Returns an identifier for the light.
-
- Light parameters are stored in world co-ordinates, not eye co-ordinates.
- The lightTransform() specifies the transformation to apply to
- convert the world co-ordinates into eye co-ordinates when the light
- is used.
-
- Note: the \a parameters may be ignored by effect() if it
- has some other way to determine the lighting conditions.
-
- The light settings in the GL server will not be changed until
- update() is called.
-
- \sa removeLight(), light(), mainLight()
-*/
-int QGLPainter::addLight(const QGLLightParameters *parameters)
-{
- return addLight(parameters, modelViewMatrix());
-}
-
-/*!
- Adds a light to this painter, with the specified \a parameters.
- The lightTransform() for the light is set to \a transform.
- Returns an identifier for the light.
-
- Light parameters are stored in world co-ordinates, not eye co-ordinates.
- The \a transform specifies the transformation to apply to
- convert the world co-ordinates into eye co-ordinates when the light
- is used.
-
- Note: the \a parameters may be ignored by effect() if it
- has some other way to determine the lighting conditions.
-
- The light settings in the GL server will not be changed until
- update() is called.
-
- \sa removeLight(), light(), mainLight()
-*/
-int QGLPainter::addLight(const QGLLightParameters *parameters, const QMatrix4x4 &transform)
-{
- Q_ASSERT(parameters);
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- int lightId = 0;
- while (lightId < d->lights.size() && d->lights[lightId] != 0)
- ++lightId;
- if (lightId < d->lights.size()) {
- d->lights[lightId] = parameters;
- d->lightTransforms[lightId] = transform;
- } else {
- d->lights.append(parameters);
- d->lightTransforms.append(transform);
- }
- d->updates |= QGLPainter::UpdateLights;
- return lightId;
-}
-
-/*!
- Removes the light with the specified \a lightId.
-
- \sa addLight(), light()
-*/
-void QGLPainter::removeLight(int lightId)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (lightId >= 0 && lightId < d->lights.size()) {
- d->lights[lightId] = 0;
- if (lightId >= (d->lights.size() - 1)) {
- do {
- d->lights.resize(lightId);
- d->lightTransforms.resize(lightId);
- --lightId;
- } while (lightId >= 0 && d->lights[lightId] == 0);
- }
- d->updates |= QGLPainter::UpdateLights;
- }
-}
-
-/*!
- Returns the maximum light identifier currently in use on this painter;
- or -1 if there are no lights.
-
- It is possible that some light identifiers less than maximumLightId()
- may be invalid because the lights have been removed. Use the following
- code to locate all enabled lights:
-
- \code
- int maxLightId = painter.maximumLightId();
- for (int lightId = 0; index <= maxLightId; ++index) {
- const QGLLightParameters *params = painter.light(lightId);
- if (params) {
- ...
- }
- }
- \endcode
-
- \sa addLight(), light()
-*/
-int QGLPainter::maximumLightId() const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return d->lights.size() - 1;
-}
-
-/*!
- Returns the parameters for the light with the identifier \a lightId;
- or null if \a lightId is not valid or has been removed.
-
- \sa addLight(), removeLight(), lightTransform()
-*/
-const QGLLightParameters *QGLPainter::light(int lightId) const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (lightId >= 0 && lightId < d->lights.size())
- return d->lights[lightId];
- else
- return 0;
-}
-
-/*!
- Returns the modelview transformation for the light with the identifier
- \a lightId; or the identity matrix if \a lightId is not valid or has
- been removed.
-
- \sa addLight(), removeLight(), light()
-*/
-QMatrix4x4 QGLPainter::lightTransform(int lightId) const
-{
- Q_D(const QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (lightId >= 0 && lightId < d->lights.size() && d->lights[lightId])
- return d->lightTransforms[lightId];
- else
- return QMatrix4x4();
-}
-
-/*!
- Returns the material that is used for drawing \a face on polygons.
- If \a face is QGL::FrontFaces or QGL::AllFaces, then the front
- material is returned. If \a face is QGL::BackFaces, then the
- back material is returned.
-
- \sa setFaceMaterial(), setFaceColor()
-*/
-const QGLMaterial *QGLPainter::faceMaterial(QGL::Face face) const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (face == QGL::BackFaces) {
- if (!d->backMaterial) {
- if (!d->defaultMaterial)
- d->defaultMaterial = new QGLMaterial();
- d->backMaterial = d->defaultMaterial;
- }
- return d->backMaterial;
- } else {
- if (!d->frontMaterial) {
- if (!d->defaultMaterial)
- d->defaultMaterial = new QGLMaterial();
- d->frontMaterial = d->defaultMaterial;
- }
- return d->frontMaterial;
- }
-}
-
-/*!
- Sets the material that is used for drawing \a face on polygons
- to \a value. If \a face is QGL::FrontFaces, then the front
- material is set. If \a face is QGL::BackFaces, then the
- back material is set. If \a face is QGL::AllFaces, then both
- the front and back materials are set.
-
- If \a value is null, then the \a face material will be set to
- the default material properties.
-
- The material settings in the GL server will not be changed until
- update() is called.
-
- \sa faceMaterial(), setFaceColor()
-*/
-void QGLPainter::setFaceMaterial
- (QGL::Face face, const QGLMaterial *value)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (face == QGL::FrontFaces) {
- if (d->frontMaterial == value)
- return;
- d->frontMaterial = value;
- } else if (face == QGL::BackFaces) {
- if (d->backMaterial == value)
- return;
- d->backMaterial = value;
- } else {
- if (d->frontMaterial == value && d->backMaterial == value)
- return;
- d->frontMaterial = value;
- d->backMaterial = value;
- }
- d->updates |= QGLPainter::UpdateMaterials;
-}
-
-static QGLMaterial *createColorMaterial
- (QGLMaterial *prev, const QColor& color)
-{
- QGLMaterial *material;
- if (prev)
- material = prev;
- else
- material = new QGLMaterial();
- material->setColor(color);
- return material;
-}
-
-/*!
- Sets the material that is used for drawing \a face on polygons
- to \a color. This is a convenience function for setting materials
- to simple colors.
-
- The RGB components of the ambient color of the material will be set
- to 20% of \a color, and the RGB components of the diffuse color of the
- material will be set to 80% of \a color. The alpha components of
- the ambient and diffuse material colors will both be set to the
- alpha component of \a color.
-
- If \a face is QGL::FrontFaces, then the front material is set.
- If \a face is QGL::BackFaces, then the back material is set.
- If \a face is QGL::AllFaces, then both the front and back
- materials are set.
-
- The material settings in the GL server will not be changed until
- update() is called.
-
- \sa faceMaterial(), setFaceMaterial()
-*/
-void QGLPainter::setFaceColor(QGL::Face face, const QColor& color)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (face == QGL::FrontFaces) {
- d->frontColorMaterial =
- createColorMaterial(d->frontColorMaterial, color);
- d->frontMaterial = d->frontColorMaterial;
- } else if (face == QGL::BackFaces) {
- d->backColorMaterial =
- createColorMaterial(d->backColorMaterial, color);
- d->backMaterial = d->backColorMaterial;
- } else {
- d->frontColorMaterial =
- createColorMaterial(d->frontColorMaterial, color);
- d->backColorMaterial =
- createColorMaterial(d->backColorMaterial, color);
- d->frontMaterial = d->frontColorMaterial;
- d->backMaterial = d->backColorMaterial;
- }
- d->updates |= QGLPainter::UpdateMaterials;
-}
-
-/*!
- Returns true if this painter is in object picking mode;
- false if this painter is in normal rendering mode.
-
- \sa setPicking(), objectPickId()
-*/
-bool QGLPainter::isPicking() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return (d->pick ? d->pick->isPicking : false);
-}
-
-/*!
- Enables or disables object picking mode according to \a value.
-
- If \a value is true, then the effect() will be overridden with a
- simple flat color effect that renders objects with pickColor().
- These colors can be read back later with pickObject().
-
- \sa isPicking(), objectPickId(), pickObject()
-*/
-void QGLPainter::setPicking(bool value)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (!d->pick)
- d->pick = new QGLPainterPickPrivate();
- if (d->pick->isPicking != value) {
- // Switch to/from the pick effect.
- d->pick->isPicking = value;
- if (d->effect)
- d->effect->setActive(this, false);
- d->effect = 0;
- d->ensureEffect(this);
- }
-}
-
-/*!
- Returns the current object pick identifier. The default value
- is -1 which indicates that rendered objects should not have a
- pickColor() associated with them.
-
- \sa setObjectPickId(), clearPickObjects(), pickObject()
-*/
-int QGLPainter::objectPickId() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- return (d->pick ? d->pick->objectPickId : -1);
-}
-
-/*!
- Sets the current object pick identifier to \a value. If \a value
- is -1, then subsequent objects will be rendered without a pickColor().
-
- If value is not -1, then the pickColor() is changed to a color
- that represents that object pick identifier. If \a value has been
- seen previously, then the same pickColor() as last time will
- be returned.
-
- The function call will be ignored if isPicking() is false.
-
- \sa objectPickId(), clearPickObjects(), pickObject()
-*/
-void QGLPainter::setObjectPickId(int value)
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (!d->pick || !d->pick->isPicking)
- return;
- d->pick->objectPickId = value;
- if (value != -1) {
- QRgb color = d->pick->pickObjectToColor.value(value, 0);
- if (!color) {
- color = qt_qgl_pick_color(d->pick->pickColorIndex++);
- d->pick->pickObjectToColor[value] = color;
- d->pick->pickColorToObject[color] = value;
- }
- d->pick->pickColor = color;
- d->updates |= UpdateColor;
- } else {
- d->pick->pickColor = 0;
- d->updates |= UpdateColor;
- }
-}
-
-/*!
- Clears the objectPickId() to pickColor() mappings that
- were used previously. This will also set objectPickId()
- to -1 and pickColor() to (0, 0, 0, 1).
-
- The function call will be ignored if isPicking() is false.
-
- \sa objectPickId(), pickColor()
-*/
-void QGLPainter::clearPickObjects()
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->pick && d->pick->isPicking) {
- d->pick->pickObjectToColor.clear();
- d->pick->pickColorToObject.clear();
- d->pick->pickColorIndex = 0;
- d->pick->objectPickId = -1;
- d->pick->pickColor = 0;
- d->updates |= UpdateColor;
- }
-}
-
-/*!
- Returns the current pick color to use to render the object
- associated with objectPickId(). The returned color will
- be (0, 0, 0, 1) if objectPickId() is -1.
-
- \sa objectPickId(), clearPickObjects()
-*/
-QColor QGLPainter::pickColor() const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
- if (d->pick) {
- QColor color;
- color.setRgb(d->pick->pickColor);
- return color;
- } else {
- return Qt::black;
- }
-}
-
-/*!
- Picks the color at (\a x, \a y) in the color buffer and
- returns the objectPickId() that corresponds to that color.
- Returns -1 if (\a x, \a y) is not positioned over a
- recognized object. The origin (0, 0) is assumed to be
- the bottom-left corner of the drawing surface.
-
- \sa objectPickId()
-*/
-int QGLPainter::pickObject(int x, int y) const
-{
- Q_D(QGLPainter);
- QGLPAINTER_CHECK_PRIVATE();
-
- if (!d->pick)
- {
- return -1;
- }
-
- // Fetch the color at the specified pixel.
- unsigned char data[4] = {0, 0, 0, 0};
- glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data);
- QRgb color = qRgb(data[0], data[1], data[2]);
-
- // Normalize the color to account for floating-point rounding.
- color = qt_qgl_normalize_pick_color(color); // XXX: detect RGB444 screens.
-
- // Map the color back to an object identifier.
- return d->pick->pickColorToObject.value(color, -1);
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qglpainter.h b/src/threed/painting/qglpainter.h
deleted file mode 100644
index 75146f69..00000000
--- a/src/threed/painting/qglpainter.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPAINTER_H
-#define QGLPAINTER_H
-
-#include <QtOpenGL/qgl.h>
-#include "qglnamespace.h"
-#include <QtGui/qvector2d.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtGui/qmatrix4x4.h>
-#include "qbox3d.h"
-#include "qopenglfunctions.h"
-#include "qglvertexbundle.h"
-#include "qglindexbuffer.h"
-#include "qgllightmodel.h"
-#include "qgllightparameters.h"
-#include "qglmaterial.h"
-#include "qglabstractsurface.h"
-#include "qmatrix4x4stack.h"
-#include "qglcamera.h"
-#include "qvector2darray.h"
-#include "qvector3darray.h"
-#include "qvector4darray.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLAbstractEffect;
-class QGLPainterPrivate;
-class QGLTexture2D;
-class QGLTextureCube;
-class QGeometryData;
-class QGLShaderProgram;
-class QGLFramebufferObject;
-class QGLSceneNode;
-class QGLRenderSequencer;
-class QGLAbstractSurface;
-
-class Q_QT3D_EXPORT QGLPainter : public QOpenGLFunctions
-{
-public:
- QGLPainter();
- explicit QGLPainter(const QGLContext *context);
- explicit QGLPainter(QGLWidget *widget);
- explicit QGLPainter(QPainter *painter);
- explicit QGLPainter(QGLAbstractSurface *surface);
- virtual ~QGLPainter();
-
- bool begin();
- bool begin(const QGLContext *context);
- bool begin(QGLWidget *widget);
- bool begin(QPainter *painter);
- bool begin(QGLAbstractSurface *surface);
- bool end();
- bool isActive() const;
-
- const QGLContext *context() const;
-
- bool isFixedFunction() const;
-
- enum Update
- {
- UpdateColor = 0x00000001,
- UpdateModelViewMatrix = 0x00000002,
- UpdateProjectionMatrix = 0x00000004,
- UpdateMatrices = 0x00000006,
- UpdateLights = 0x00000008,
- UpdateMaterials = 0x00000010,
- UpdateViewport = 0x00000020,
- UpdateAll = 0x7FFFFFFF
- };
- Q_DECLARE_FLAGS(Updates, Update);
-
- void setClearColor(const QColor& color);
-
- void setScissor(const QRect& rect);
-
- QMatrix4x4Stack& projectionMatrix();
- QMatrix4x4Stack& modelViewMatrix();
- QMatrix4x4 combinedMatrix() const;
- QMatrix3x3 normalMatrix() const;
- QMatrix4x4 worldMatrix() const;
-
- QGL::Eye eye() const;
- void setEye(QGL::Eye eye);
-
- void setCamera(const QGLCamera *camera);
-
- bool isCullable(const QVector3D& point) const;
- bool isCullable(const QBox3D& box) const;
- QGLRenderSequencer *renderSequencer();
-
- qreal aspectRatio() const;
-
- QGLAbstractEffect *effect() const;
-
- QGLAbstractEffect *userEffect() const;
- void setUserEffect(QGLAbstractEffect *effect);
-
- QGL::StandardEffect standardEffect() const;
- void setStandardEffect(QGL::StandardEffect effect);
-
- void disableEffect();
-
- QGLShaderProgram *cachedProgram(const QString& name) const;
- void setCachedProgram(const QString& name, QGLShaderProgram *program);
-
- QColor color() const;
- void setColor(const QColor& color);
-
- QGLAttributeSet attributes() const;
- void clearAttributes();
-
- void setVertexAttribute
- (QGL::VertexAttribute attribute, const QGLAttributeValue& value);
- void setVertexBundle(const QGLVertexBundle& buffer);
-
- void update();
- void updateFixedFunction(QGLPainter::Updates updates);
-
- void draw(QGL::DrawingMode mode, int count, int index = 0);
- void draw(QGL::DrawingMode mode, const ushort *indices, int count);
- void draw(QGL::DrawingMode mode, const QGLIndexBuffer& indices);
- virtual void draw(QGL::DrawingMode mode, const QGLIndexBuffer& indices, int offset, int count);
-
- void pushSurface(QGLAbstractSurface *surface);
- QGLAbstractSurface *popSurface();
- void setSurface(QGLAbstractSurface *surface);
- QGLAbstractSurface *currentSurface() const;
-
- const QGLLightModel *lightModel() const;
- void setLightModel(const QGLLightModel *value);
-
- const QGLLightParameters *mainLight() const;
- void setMainLight(const QGLLightParameters *parameters);
- void setMainLight
- (const QGLLightParameters *parameters, const QMatrix4x4& transform);
- QMatrix4x4 mainLightTransform() const;
-
- int addLight(const QGLLightParameters *parameters);
- int addLight(const QGLLightParameters *parameters, const QMatrix4x4 &transform);
- void removeLight(int lightId);
-
- int maximumLightId() const;
- const QGLLightParameters *light(int lightId) const;
- QMatrix4x4 lightTransform(int lightId) const;
-
- const QGLMaterial *faceMaterial(QGL::Face face) const;
- void setFaceMaterial(QGL::Face face, const QGLMaterial *value);
- void setFaceColor(QGL::Face face, const QColor& color);
-
- bool isPicking() const;
- void setPicking(bool value);
-
- int objectPickId() const;
- void setObjectPickId(int value);
- void clearPickObjects();
-
- QColor pickColor() const;
-
- int pickObject(int x, int y) const;
-
-private:
- Q_DISABLE_COPY(QGLPainter)
-
- QGLPainterPrivate *d_ptr;
-
- QGLPainterPrivate *d_func() const { return d_ptr; }
-
- friend class QGLAbstractEffect;
-
- bool begin(const QGLContext *context, QGLAbstractSurface *surface,
- bool destroySurface = true);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLPainter::Updates)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qglpainter_p.h b/src/threed/painting/qglpainter_p.h
deleted file mode 100644
index bd1a0c6b..00000000
--- a/src/threed/painting/qglpainter_p.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPAINTER_P_H
-#define QGLPAINTER_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.
-//
-
-#include "qglpainter.h"
-#include "qglrendersequencer.h"
-
-#include <QtCore/qatomic.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qstack.h>
-
-QT_BEGIN_NAMESPACE
-
-#define QGL_MAX_LIGHTS 32
-#define QGL_MAX_STD_EFFECTS 16
-
-class QGLPainterPickPrivate
-{
-public:
- QGLPainterPickPrivate();
- ~QGLPainterPickPrivate();
-
- bool isPicking;
- int objectPickId;
- int pickColorIndex;
- QRgb pickColor;
- QMap<int, QRgb> pickObjectToColor;
- QMap<QRgb, int> pickColorToObject;
- QGLAbstractEffect *defaultPickEffect;
-};
-
-struct QGLPainterSurfaceInfo
-{
- QGLAbstractSurface *surface;
- bool destroySurface;
- bool mainSurface;
-};
-
-class QGLPainterPrivate
-{
-public:
- QGLPainterPrivate();
- ~QGLPainterPrivate();
-
- QAtomicInt ref;
- const QGLContext *context;
- QMatrix4x4Stack projectionMatrix;
- QMatrix4x4Stack modelViewMatrix;
- QMatrix4x4 inverseEyeMatrix;
- QGL::Eye eye;
- QGLAbstractEffect *effect;
- QGLAbstractEffect *userEffect;
- QGL::StandardEffect standardEffect;
- QGLAbstractEffect *stdeffects[QGL_MAX_STD_EFFECTS];
- const QGLLightModel *lightModel;
- QGLLightModel *defaultLightModel;
- QGLLightParameters *defaultLight;
- QArray<const QGLLightParameters *> lights;
- QArray<QMatrix4x4> lightTransforms;
- const QGLMaterial *frontMaterial;
- const QGLMaterial *backMaterial;
- QGLMaterial *defaultMaterial;
- QGLMaterial *frontColorMaterial;
- QGLMaterial *backColorMaterial;
- QBox3D viewingCube;
- QColor color;
- QGLPainter::Updates updates;
- QGLPainterPickPrivate *pick;
- QMap<QString, QGLShaderProgram *> cachedPrograms;
- QStack<QGLPainterSurfaceInfo> surfaceStack;
- GLuint boundVertexBuffer;
- GLuint boundIndexBuffer;
- QGLRenderSequencer *renderSequencer;
- bool isFixedFunction;
- QGLAttributeSet attributeSet;
-
- inline void ensureEffect(QGLPainter *painter)
- { if (!effect) createEffect(painter); }
- void createEffect(QGLPainter *painter);
-};
-
-class QGLPainterPrivateCache : public QObject
-{
- Q_OBJECT
-public:
- QGLPainterPrivateCache();
- ~QGLPainterPrivateCache();
-
- QMap<const QGLContext *, QGLPainterPrivate *> cache;
-
- QGLPainterPrivate *fromContext(const QGLContext *context);
-
- static QGLPainterPrivateCache *instance();
-
-public Q_SLOTS:
- void contextDestroyed(const QGLContext *context);
-
-Q_SIGNALS:
- void destroyedContext(const QGLContext *context);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/painting/qglpickcolors.cpp b/src/threed/painting/qglpickcolors.cpp
deleted file mode 100644
index e5a20958..00000000
--- a/src/threed/painting/qglpickcolors.cpp
+++ /dev/null
@@ -1,1125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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$
-**
-****************************************************************************/
-
-#if !defined(QGL_GENERATOR_PROGRAM)
-
-#include "qglpickcolors_p.h"
-
-QT_BEGIN_NAMESPACE
-
-// The following tables are generated by the program listed at the
-// end of this source file.
-
-static int const pickColors[4096] = {
- 0xffffff, 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff,
- 0xff8000, 0x80ff00, 0x8000ff, 0xff0080, 0x0080ff, 0x00ff80, 0xff80ff,
- 0x80ffff, 0xffff80, 0x80ff80, 0xff8080, 0x8080ff, 0x808080, 0x800000,
- 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xff80c0, 0x80c0ff,
- 0xc0ff80, 0xffc080, 0x80ffc0, 0xc080ff, 0xffc000, 0xc0ff00, 0xc000ff,
- 0xff00c0, 0x00c0ff, 0x00ffc0, 0xffc0ff, 0xc0ffff, 0xffffc0, 0xc0ffc0,
- 0xffc0c0, 0xc0c0ff, 0x80c000, 0xc08000, 0xc00080, 0x8000c0, 0x00c080,
- 0x0080c0, 0x80c080, 0xc08080, 0x8080c0, 0xc080c0, 0x80c0c0, 0xc0c080,
- 0xc0c0c0, 0xc00000, 0x00c000, 0x0000c0, 0xc0c000, 0xc000c0, 0x00c0c0,
- 0xff8040, 0x8040ff, 0x40ff80, 0xff4080, 0x80ff40, 0x4080ff, 0xffc040,
- 0xc040ff, 0x40ffc0, 0xff40c0, 0xc0ff40, 0x40c0ff, 0xff4000, 0x40ff00,
- 0x4000ff, 0xff0040, 0x0040ff, 0x00ff40, 0xff40ff, 0x40ffff, 0xffff40,
- 0x40ff40, 0xff4040, 0x4040ff, 0x80c040, 0xc04080, 0x4080c0, 0x8040c0,
- 0xc08040, 0x40c080, 0x804000, 0x408000, 0x400080, 0x800040, 0x004080,
- 0x008040, 0x804080, 0x408080, 0x808040, 0x408040, 0x804040, 0x404080,
- 0xc04000, 0x40c000, 0x4000c0, 0xc00040, 0x0040c0, 0x00c040, 0xc040c0,
- 0x40c0c0, 0xc0c040, 0x40c040, 0xc04040, 0x4040c0, 0x404040, 0x400000,
- 0x004000, 0x000040, 0x404000, 0x400040, 0x004040, 0xff80e0, 0x80e0ff,
- 0xe0ff80, 0xffe080, 0x80ffe0, 0xe080ff, 0xffc0e0, 0xc0e0ff, 0xe0ffc0,
- 0xffe0c0, 0xc0ffe0, 0xe0c0ff, 0xff40e0, 0x40e0ff, 0xe0ff40, 0xffe040,
- 0x40ffe0, 0xe040ff, 0xffe000, 0xe0ff00, 0xe000ff, 0xff00e0, 0x00e0ff,
- 0x00ffe0, 0xffe0ff, 0xe0ffff, 0xffffe0, 0xe0ffe0, 0xffe0e0, 0xe0e0ff,
- 0x80c0e0, 0xc0e080, 0xe080c0, 0x80e0c0, 0xc080e0, 0xe0c080, 0x8040e0,
- 0x40e080, 0xe08040, 0x80e040, 0x4080e0, 0xe04080, 0x80e000, 0xe08000,
- 0xe00080, 0x8000e0, 0x00e080, 0x0080e0, 0x80e080, 0xe08080, 0x8080e0,
- 0xe080e0, 0x80e0e0, 0xe0e080, 0xc040e0, 0x40e0c0, 0xe0c040, 0xc0e040,
- 0x40c0e0, 0xe040c0, 0xc0e000, 0xe0c000, 0xe000c0, 0xc000e0, 0x00e0c0,
- 0x00c0e0, 0xc0e0c0, 0xe0c0c0, 0xc0c0e0, 0xe0c0e0, 0xc0e0e0, 0xe0e0c0,
- 0x40e000, 0xe04000, 0xe00040, 0x4000e0, 0x00e040, 0x0040e0, 0x40e040,
- 0xe04040, 0x4040e0, 0xe040e0, 0x40e0e0, 0xe0e040, 0xe0e0e0, 0xe00000,
- 0x00e000, 0x0000e0, 0xe0e000, 0xe000e0, 0x00e0e0, 0xff8060, 0x8060ff,
- 0x60ff80, 0xff6080, 0x80ff60, 0x6080ff, 0xffc060, 0xc060ff, 0x60ffc0,
- 0xff60c0, 0xc0ff60, 0x60c0ff, 0xff4060, 0x4060ff, 0x60ff40, 0xff6040,
- 0x40ff60, 0x6040ff, 0xffe060, 0xe060ff, 0x60ffe0, 0xff60e0, 0xe0ff60,
- 0x60e0ff, 0xff6000, 0x60ff00, 0x6000ff, 0xff0060, 0x0060ff, 0x00ff60,
- 0xff60ff, 0x60ffff, 0xffff60, 0x60ff60, 0xff6060, 0x6060ff, 0x80c060,
- 0xc06080, 0x6080c0, 0x8060c0, 0xc08060, 0x60c080, 0x804060, 0x406080,
- 0x608040, 0x806040, 0x408060, 0x604080, 0x80e060, 0xe06080, 0x6080e0,
- 0x8060e0, 0xe08060, 0x60e080, 0x806000, 0x608000, 0x600080, 0x800060,
- 0x006080, 0x008060, 0x806080, 0x608080, 0x808060, 0x608060, 0x806060,
- 0x606080, 0xc04060, 0x4060c0, 0x60c040, 0xc06040, 0x40c060, 0x6040c0,
- 0xc0e060, 0xe060c0, 0x60c0e0, 0xc060e0, 0xe0c060, 0x60e0c0, 0xc06000,
- 0x60c000, 0x6000c0, 0xc00060, 0x0060c0, 0x00c060, 0xc060c0, 0x60c0c0,
- 0xc0c060, 0x60c060, 0xc06060, 0x6060c0, 0x40e060, 0xe06040, 0x6040e0,
- 0x4060e0, 0xe04060, 0x60e040, 0x406000, 0x604000, 0x600040, 0x400060,
- 0x006040, 0x004060, 0x406040, 0x604040, 0x404060, 0x604060, 0x406060,
- 0x606040, 0xe06000, 0x60e000, 0x6000e0, 0xe00060, 0x0060e0, 0x00e060,
- 0xe060e0, 0x60e0e0, 0xe0e060, 0x60e060, 0xe06060, 0x6060e0, 0x606060,
- 0x600000, 0x006000, 0x000060, 0x606000, 0x600060, 0x006060, 0xff80a0,
- 0x80a0ff, 0xa0ff80, 0xffa080, 0x80ffa0, 0xa080ff, 0xffc0a0, 0xc0a0ff,
- 0xa0ffc0, 0xffa0c0, 0xc0ffa0, 0xa0c0ff, 0xff40a0, 0x40a0ff, 0xa0ff40,
- 0xffa040, 0x40ffa0, 0xa040ff, 0xffe0a0, 0xe0a0ff, 0xa0ffe0, 0xffa0e0,
- 0xe0ffa0, 0xa0e0ff, 0xff60a0, 0x60a0ff, 0xa0ff60, 0xffa060, 0x60ffa0,
- 0xa060ff, 0xffa000, 0xa0ff00, 0xa000ff, 0xff00a0, 0x00a0ff, 0x00ffa0,
- 0xffa0ff, 0xa0ffff, 0xffffa0, 0xa0ffa0, 0xffa0a0, 0xa0a0ff, 0x80c0a0,
- 0xc0a080, 0xa080c0, 0x80a0c0, 0xc080a0, 0xa0c080, 0x8040a0, 0x40a080,
- 0xa08040, 0x80a040, 0x4080a0, 0xa04080, 0x80e0a0, 0xe0a080, 0xa080e0,
- 0x80a0e0, 0xe080a0, 0xa0e080, 0x8060a0, 0x60a080, 0xa08060, 0x80a060,
- 0x6080a0, 0xa06080, 0x80a000, 0xa08000, 0xa00080, 0x8000a0, 0x00a080,
- 0x0080a0, 0x80a080, 0xa08080, 0x8080a0, 0xa080a0, 0x80a0a0, 0xa0a080,
- 0xc040a0, 0x40a0c0, 0xa0c040, 0xc0a040, 0x40c0a0, 0xa040c0, 0xc0e0a0,
- 0xe0a0c0, 0xa0c0e0, 0xc0a0e0, 0xe0c0a0, 0xa0e0c0, 0xc060a0, 0x60a0c0,
- 0xa0c060, 0xc0a060, 0x60c0a0, 0xa060c0, 0xc0a000, 0xa0c000, 0xa000c0,
- 0xc000a0, 0x00a0c0, 0x00c0a0, 0xc0a0c0, 0xa0c0c0, 0xc0c0a0, 0xa0c0a0,
- 0xc0a0a0, 0xa0a0c0, 0x40e0a0, 0xe0a040, 0xa040e0, 0x40a0e0, 0xe040a0,
- 0xa0e040, 0x4060a0, 0x60a040, 0xa04060, 0x40a060, 0x6040a0, 0xa06040,
- 0x40a000, 0xa04000, 0xa00040, 0x4000a0, 0x00a040, 0x0040a0, 0x40a040,
- 0xa04040, 0x4040a0, 0xa040a0, 0x40a0a0, 0xa0a040, 0xe060a0, 0x60a0e0,
- 0xa0e060, 0xe0a060, 0x60e0a0, 0xa060e0, 0xe0a000, 0xa0e000, 0xa000e0,
- 0xe000a0, 0x00a0e0, 0x00e0a0, 0xe0a0e0, 0xa0e0e0, 0xe0e0a0, 0xa0e0a0,
- 0xe0a0a0, 0xa0a0e0, 0x60a000, 0xa06000, 0xa00060, 0x6000a0, 0x00a060,
- 0x0060a0, 0x60a060, 0xa06060, 0x6060a0, 0xa060a0, 0x60a0a0, 0xa0a060,
- 0xa0a0a0, 0xa00000, 0x00a000, 0x0000a0, 0xa0a000, 0xa000a0, 0x00a0a0,
- 0xff8020, 0x8020ff, 0x20ff80, 0xff2080, 0x80ff20, 0x2080ff, 0xffc020,
- 0xc020ff, 0x20ffc0, 0xff20c0, 0xc0ff20, 0x20c0ff, 0xff4020, 0x4020ff,
- 0x20ff40, 0xff2040, 0x40ff20, 0x2040ff, 0xffe020, 0xe020ff, 0x20ffe0,
- 0xff20e0, 0xe0ff20, 0x20e0ff, 0xff6020, 0x6020ff, 0x20ff60, 0xff2060,
- 0x60ff20, 0x2060ff, 0xffa020, 0xa020ff, 0x20ffa0, 0xff20a0, 0xa0ff20,
- 0x20a0ff, 0xff2000, 0x20ff00, 0x2000ff, 0xff0020, 0x0020ff, 0x00ff20,
- 0xff20ff, 0x20ffff, 0xffff20, 0x20ff20, 0xff2020, 0x2020ff, 0x80c020,
- 0xc02080, 0x2080c0, 0x8020c0, 0xc08020, 0x20c080, 0x804020, 0x402080,
- 0x208040, 0x802040, 0x408020, 0x204080, 0x80e020, 0xe02080, 0x2080e0,
- 0x8020e0, 0xe08020, 0x20e080, 0x806020, 0x602080, 0x208060, 0x802060,
- 0x608020, 0x206080, 0x80a020, 0xa02080, 0x2080a0, 0x8020a0, 0xa08020,
- 0x20a080, 0x802000, 0x208000, 0x200080, 0x800020, 0x002080, 0x008020,
- 0x802080, 0x208080, 0x808020, 0x208020, 0x802020, 0x202080, 0xc04020,
- 0x4020c0, 0x20c040, 0xc02040, 0x40c020, 0x2040c0, 0xc0e020, 0xe020c0,
- 0x20c0e0, 0xc020e0, 0xe0c020, 0x20e0c0, 0xc06020, 0x6020c0, 0x20c060,
- 0xc02060, 0x60c020, 0x2060c0, 0xc0a020, 0xa020c0, 0x20c0a0, 0xc020a0,
- 0xa0c020, 0x20a0c0, 0xc02000, 0x20c000, 0x2000c0, 0xc00020, 0x0020c0,
- 0x00c020, 0xc020c0, 0x20c0c0, 0xc0c020, 0x20c020, 0xc02020, 0x2020c0,
- 0x40e020, 0xe02040, 0x2040e0, 0x4020e0, 0xe04020, 0x20e040, 0x406020,
- 0x602040, 0x204060, 0x402060, 0x604020, 0x206040, 0x40a020, 0xa02040,
- 0x2040a0, 0x4020a0, 0xa04020, 0x20a040, 0x402000, 0x204000, 0x200040,
- 0x400020, 0x002040, 0x004020, 0x402040, 0x204040, 0x404020, 0x204020,
- 0x402020, 0x202040, 0xe06020, 0x6020e0, 0x20e060, 0xe02060, 0x60e020,
- 0x2060e0, 0xe0a020, 0xa020e0, 0x20e0a0, 0xe020a0, 0xa0e020, 0x20a0e0,
- 0xe02000, 0x20e000, 0x2000e0, 0xe00020, 0x0020e0, 0x00e020, 0xe020e0,
- 0x20e0e0, 0xe0e020, 0x20e020, 0xe02020, 0x2020e0, 0x60a020, 0xa02060,
- 0x2060a0, 0x6020a0, 0xa06020, 0x20a060, 0x602000, 0x206000, 0x200060,
- 0x600020, 0x002060, 0x006020, 0x602060, 0x206060, 0x606020, 0x206020,
- 0x602020, 0x202060, 0xa02000, 0x20a000, 0x2000a0, 0xa00020, 0x0020a0,
- 0x00a020, 0xa020a0, 0x20a0a0, 0xa0a020, 0x20a020, 0xa02020, 0x2020a0,
- 0x202020, 0x200000, 0x002000, 0x000020, 0x202000, 0x200020, 0x002020,
- 0xff80f0, 0x80f0ff, 0xf0ff80, 0xfff080, 0x80fff0, 0xf080ff, 0xffc0f0,
- 0xc0f0ff, 0xf0ffc0, 0xfff0c0, 0xc0fff0, 0xf0c0ff, 0xff40f0, 0x40f0ff,
- 0xf0ff40, 0xfff040, 0x40fff0, 0xf040ff, 0xffe0f0, 0xe0f0ff, 0xf0ffe0,
- 0xfff0e0, 0xe0fff0, 0xf0e0ff, 0xff60f0, 0x60f0ff, 0xf0ff60, 0xfff060,
- 0x60fff0, 0xf060ff, 0xffa0f0, 0xa0f0ff, 0xf0ffa0, 0xfff0a0, 0xa0fff0,
- 0xf0a0ff, 0xff20f0, 0x20f0ff, 0xf0ff20, 0xfff020, 0x20fff0, 0xf020ff,
- 0xfff000, 0xf0ff00, 0xf000ff, 0xff00f0, 0x00f0ff, 0x00fff0, 0xfff0ff,
- 0xf0ffff, 0xfffff0, 0xf0fff0, 0xfff0f0, 0xf0f0ff, 0x80c0f0, 0xc0f080,
- 0xf080c0, 0x80f0c0, 0xc080f0, 0xf0c080, 0x8040f0, 0x40f080, 0xf08040,
- 0x80f040, 0x4080f0, 0xf04080, 0x80e0f0, 0xe0f080, 0xf080e0, 0x80f0e0,
- 0xe080f0, 0xf0e080, 0x8060f0, 0x60f080, 0xf08060, 0x80f060, 0x6080f0,
- 0xf06080, 0x80a0f0, 0xa0f080, 0xf080a0, 0x80f0a0, 0xa080f0, 0xf0a080,
- 0x8020f0, 0x20f080, 0xf08020, 0x80f020, 0x2080f0, 0xf02080, 0x80f000,
- 0xf08000, 0xf00080, 0x8000f0, 0x00f080, 0x0080f0, 0x80f080, 0xf08080,
- 0x8080f0, 0xf080f0, 0x80f0f0, 0xf0f080, 0xc040f0, 0x40f0c0, 0xf0c040,
- 0xc0f040, 0x40c0f0, 0xf040c0, 0xc0e0f0, 0xe0f0c0, 0xf0c0e0, 0xc0f0e0,
- 0xe0c0f0, 0xf0e0c0, 0xc060f0, 0x60f0c0, 0xf0c060, 0xc0f060, 0x60c0f0,
- 0xf060c0, 0xc0a0f0, 0xa0f0c0, 0xf0c0a0, 0xc0f0a0, 0xa0c0f0, 0xf0a0c0,
- 0xc020f0, 0x20f0c0, 0xf0c020, 0xc0f020, 0x20c0f0, 0xf020c0, 0xc0f000,
- 0xf0c000, 0xf000c0, 0xc000f0, 0x00f0c0, 0x00c0f0, 0xc0f0c0, 0xf0c0c0,
- 0xc0c0f0, 0xf0c0f0, 0xc0f0f0, 0xf0f0c0, 0x40e0f0, 0xe0f040, 0xf040e0,
- 0x40f0e0, 0xe040f0, 0xf0e040, 0x4060f0, 0x60f040, 0xf04060, 0x40f060,
- 0x6040f0, 0xf06040, 0x40a0f0, 0xa0f040, 0xf040a0, 0x40f0a0, 0xa040f0,
- 0xf0a040, 0x4020f0, 0x20f040, 0xf04020, 0x40f020, 0x2040f0, 0xf02040,
- 0x40f000, 0xf04000, 0xf00040, 0x4000f0, 0x00f040, 0x0040f0, 0x40f040,
- 0xf04040, 0x4040f0, 0xf040f0, 0x40f0f0, 0xf0f040, 0xe060f0, 0x60f0e0,
- 0xf0e060, 0xe0f060, 0x60e0f0, 0xf060e0, 0xe0a0f0, 0xa0f0e0, 0xf0e0a0,
- 0xe0f0a0, 0xa0e0f0, 0xf0a0e0, 0xe020f0, 0x20f0e0, 0xf0e020, 0xe0f020,
- 0x20e0f0, 0xf020e0, 0xe0f000, 0xf0e000, 0xf000e0, 0xe000f0, 0x00f0e0,
- 0x00e0f0, 0xe0f0e0, 0xf0e0e0, 0xe0e0f0, 0xf0e0f0, 0xe0f0f0, 0xf0f0e0,
- 0x60a0f0, 0xa0f060, 0xf060a0, 0x60f0a0, 0xa060f0, 0xf0a060, 0x6020f0,
- 0x20f060, 0xf06020, 0x60f020, 0x2060f0, 0xf02060, 0x60f000, 0xf06000,
- 0xf00060, 0x6000f0, 0x00f060, 0x0060f0, 0x60f060, 0xf06060, 0x6060f0,
- 0xf060f0, 0x60f0f0, 0xf0f060, 0xa020f0, 0x20f0a0, 0xf0a020, 0xa0f020,
- 0x20a0f0, 0xf020a0, 0xa0f000, 0xf0a000, 0xf000a0, 0xa000f0, 0x00f0a0,
- 0x00a0f0, 0xa0f0a0, 0xf0a0a0, 0xa0a0f0, 0xf0a0f0, 0xa0f0f0, 0xf0f0a0,
- 0x20f000, 0xf02000, 0xf00020, 0x2000f0, 0x00f020, 0x0020f0, 0x20f020,
- 0xf02020, 0x2020f0, 0xf020f0, 0x20f0f0, 0xf0f020, 0xf0f0f0, 0xf00000,
- 0x00f000, 0x0000f0, 0xf0f000, 0xf000f0, 0x00f0f0, 0xff80b0, 0x80b0ff,
- 0xb0ff80, 0xffb080, 0x80ffb0, 0xb080ff, 0xffc0b0, 0xc0b0ff, 0xb0ffc0,
- 0xffb0c0, 0xc0ffb0, 0xb0c0ff, 0xff40b0, 0x40b0ff, 0xb0ff40, 0xffb040,
- 0x40ffb0, 0xb040ff, 0xffe0b0, 0xe0b0ff, 0xb0ffe0, 0xffb0e0, 0xe0ffb0,
- 0xb0e0ff, 0xff60b0, 0x60b0ff, 0xb0ff60, 0xffb060, 0x60ffb0, 0xb060ff,
- 0xffa0b0, 0xa0b0ff, 0xb0ffa0, 0xffb0a0, 0xa0ffb0, 0xb0a0ff, 0xff20b0,
- 0x20b0ff, 0xb0ff20, 0xffb020, 0x20ffb0, 0xb020ff, 0xfff0b0, 0xf0b0ff,
- 0xb0fff0, 0xffb0f0, 0xf0ffb0, 0xb0f0ff, 0xffb000, 0xb0ff00, 0xb000ff,
- 0xff00b0, 0x00b0ff, 0x00ffb0, 0xffb0ff, 0xb0ffff, 0xffffb0, 0xb0ffb0,
- 0xffb0b0, 0xb0b0ff, 0x80c0b0, 0xc0b080, 0xb080c0, 0x80b0c0, 0xc080b0,
- 0xb0c080, 0x8040b0, 0x40b080, 0xb08040, 0x80b040, 0x4080b0, 0xb04080,
- 0x80e0b0, 0xe0b080, 0xb080e0, 0x80b0e0, 0xe080b0, 0xb0e080, 0x8060b0,
- 0x60b080, 0xb08060, 0x80b060, 0x6080b0, 0xb06080, 0x80a0b0, 0xa0b080,
- 0xb080a0, 0x80b0a0, 0xa080b0, 0xb0a080, 0x8020b0, 0x20b080, 0xb08020,
- 0x80b020, 0x2080b0, 0xb02080, 0x80f0b0, 0xf0b080, 0xb080f0, 0x80b0f0,
- 0xf080b0, 0xb0f080, 0x80b000, 0xb08000, 0xb00080, 0x8000b0, 0x00b080,
- 0x0080b0, 0x80b080, 0xb08080, 0x8080b0, 0xb080b0, 0x80b0b0, 0xb0b080,
- 0xc040b0, 0x40b0c0, 0xb0c040, 0xc0b040, 0x40c0b0, 0xb040c0, 0xc0e0b0,
- 0xe0b0c0, 0xb0c0e0, 0xc0b0e0, 0xe0c0b0, 0xb0e0c0, 0xc060b0, 0x60b0c0,
- 0xb0c060, 0xc0b060, 0x60c0b0, 0xb060c0, 0xc0a0b0, 0xa0b0c0, 0xb0c0a0,
- 0xc0b0a0, 0xa0c0b0, 0xb0a0c0, 0xc020b0, 0x20b0c0, 0xb0c020, 0xc0b020,
- 0x20c0b0, 0xb020c0, 0xc0f0b0, 0xf0b0c0, 0xb0c0f0, 0xc0b0f0, 0xf0c0b0,
- 0xb0f0c0, 0xc0b000, 0xb0c000, 0xb000c0, 0xc000b0, 0x00b0c0, 0x00c0b0,
- 0xc0b0c0, 0xb0c0c0, 0xc0c0b0, 0xb0c0b0, 0xc0b0b0, 0xb0b0c0, 0x40e0b0,
- 0xe0b040, 0xb040e0, 0x40b0e0, 0xe040b0, 0xb0e040, 0x4060b0, 0x60b040,
- 0xb04060, 0x40b060, 0x6040b0, 0xb06040, 0x40a0b0, 0xa0b040, 0xb040a0,
- 0x40b0a0, 0xa040b0, 0xb0a040, 0x4020b0, 0x20b040, 0xb04020, 0x40b020,
- 0x2040b0, 0xb02040, 0x40f0b0, 0xf0b040, 0xb040f0, 0x40b0f0, 0xf040b0,
- 0xb0f040, 0x40b000, 0xb04000, 0xb00040, 0x4000b0, 0x00b040, 0x0040b0,
- 0x40b040, 0xb04040, 0x4040b0, 0xb040b0, 0x40b0b0, 0xb0b040, 0xe060b0,
- 0x60b0e0, 0xb0e060, 0xe0b060, 0x60e0b0, 0xb060e0, 0xe0a0b0, 0xa0b0e0,
- 0xb0e0a0, 0xe0b0a0, 0xa0e0b0, 0xb0a0e0, 0xe020b0, 0x20b0e0, 0xb0e020,
- 0xe0b020, 0x20e0b0, 0xb020e0, 0xe0f0b0, 0xf0b0e0, 0xb0e0f0, 0xe0b0f0,
- 0xf0e0b0, 0xb0f0e0, 0xe0b000, 0xb0e000, 0xb000e0, 0xe000b0, 0x00b0e0,
- 0x00e0b0, 0xe0b0e0, 0xb0e0e0, 0xe0e0b0, 0xb0e0b0, 0xe0b0b0, 0xb0b0e0,
- 0x60a0b0, 0xa0b060, 0xb060a0, 0x60b0a0, 0xa060b0, 0xb0a060, 0x6020b0,
- 0x20b060, 0xb06020, 0x60b020, 0x2060b0, 0xb02060, 0x60f0b0, 0xf0b060,
- 0xb060f0, 0x60b0f0, 0xf060b0, 0xb0f060, 0x60b000, 0xb06000, 0xb00060,
- 0x6000b0, 0x00b060, 0x0060b0, 0x60b060, 0xb06060, 0x6060b0, 0xb060b0,
- 0x60b0b0, 0xb0b060, 0xa020b0, 0x20b0a0, 0xb0a020, 0xa0b020, 0x20a0b0,
- 0xb020a0, 0xa0f0b0, 0xf0b0a0, 0xb0a0f0, 0xa0b0f0, 0xf0a0b0, 0xb0f0a0,
- 0xa0b000, 0xb0a000, 0xb000a0, 0xa000b0, 0x00b0a0, 0x00a0b0, 0xa0b0a0,
- 0xb0a0a0, 0xa0a0b0, 0xb0a0b0, 0xa0b0b0, 0xb0b0a0, 0x20f0b0, 0xf0b020,
- 0xb020f0, 0x20b0f0, 0xf020b0, 0xb0f020, 0x20b000, 0xb02000, 0xb00020,
- 0x2000b0, 0x00b020, 0x0020b0, 0x20b020, 0xb02020, 0x2020b0, 0xb020b0,
- 0x20b0b0, 0xb0b020, 0xf0b000, 0xb0f000, 0xb000f0, 0xf000b0, 0x00b0f0,
- 0x00f0b0, 0xf0b0f0, 0xb0f0f0, 0xf0f0b0, 0xb0f0b0, 0xf0b0b0, 0xb0b0f0,
- 0xb0b0b0, 0xb00000, 0x00b000, 0x0000b0, 0xb0b000, 0xb000b0, 0x00b0b0,
- 0xff8050, 0x8050ff, 0x50ff80, 0xff5080, 0x80ff50, 0x5080ff, 0xffc050,
- 0xc050ff, 0x50ffc0, 0xff50c0, 0xc0ff50, 0x50c0ff, 0xff4050, 0x4050ff,
- 0x50ff40, 0xff5040, 0x40ff50, 0x5040ff, 0xffe050, 0xe050ff, 0x50ffe0,
- 0xff50e0, 0xe0ff50, 0x50e0ff, 0xff6050, 0x6050ff, 0x50ff60, 0xff5060,
- 0x60ff50, 0x5060ff, 0xffa050, 0xa050ff, 0x50ffa0, 0xff50a0, 0xa0ff50,
- 0x50a0ff, 0xff2050, 0x2050ff, 0x50ff20, 0xff5020, 0x20ff50, 0x5020ff,
- 0xfff050, 0xf050ff, 0x50fff0, 0xff50f0, 0xf0ff50, 0x50f0ff, 0xffb050,
- 0xb050ff, 0x50ffb0, 0xff50b0, 0xb0ff50, 0x50b0ff, 0xff5000, 0x50ff00,
- 0x5000ff, 0xff0050, 0x0050ff, 0x00ff50, 0xff50ff, 0x50ffff, 0xffff50,
- 0x50ff50, 0xff5050, 0x5050ff, 0x80c050, 0xc05080, 0x5080c0, 0x8050c0,
- 0xc08050, 0x50c080, 0x804050, 0x405080, 0x508040, 0x805040, 0x408050,
- 0x504080, 0x80e050, 0xe05080, 0x5080e0, 0x8050e0, 0xe08050, 0x50e080,
- 0x806050, 0x605080, 0x508060, 0x805060, 0x608050, 0x506080, 0x80a050,
- 0xa05080, 0x5080a0, 0x8050a0, 0xa08050, 0x50a080, 0x802050, 0x205080,
- 0x508020, 0x805020, 0x208050, 0x502080, 0x80f050, 0xf05080, 0x5080f0,
- 0x8050f0, 0xf08050, 0x50f080, 0x80b050, 0xb05080, 0x5080b0, 0x8050b0,
- 0xb08050, 0x50b080, 0x805000, 0x508000, 0x500080, 0x800050, 0x005080,
- 0x008050, 0x805080, 0x508080, 0x808050, 0x508050, 0x805050, 0x505080,
- 0xc04050, 0x4050c0, 0x50c040, 0xc05040, 0x40c050, 0x5040c0, 0xc0e050,
- 0xe050c0, 0x50c0e0, 0xc050e0, 0xe0c050, 0x50e0c0, 0xc06050, 0x6050c0,
- 0x50c060, 0xc05060, 0x60c050, 0x5060c0, 0xc0a050, 0xa050c0, 0x50c0a0,
- 0xc050a0, 0xa0c050, 0x50a0c0, 0xc02050, 0x2050c0, 0x50c020, 0xc05020,
- 0x20c050, 0x5020c0, 0xc0f050, 0xf050c0, 0x50c0f0, 0xc050f0, 0xf0c050,
- 0x50f0c0, 0xc0b050, 0xb050c0, 0x50c0b0, 0xc050b0, 0xb0c050, 0x50b0c0,
- 0xc05000, 0x50c000, 0x5000c0, 0xc00050, 0x0050c0, 0x00c050, 0xc050c0,
- 0x50c0c0, 0xc0c050, 0x50c050, 0xc05050, 0x5050c0, 0x40e050, 0xe05040,
- 0x5040e0, 0x4050e0, 0xe04050, 0x50e040, 0x406050, 0x605040, 0x504060,
- 0x405060, 0x604050, 0x506040, 0x40a050, 0xa05040, 0x5040a0, 0x4050a0,
- 0xa04050, 0x50a040, 0x402050, 0x205040, 0x504020, 0x405020, 0x204050,
- 0x502040, 0x40f050, 0xf05040, 0x5040f0, 0x4050f0, 0xf04050, 0x50f040,
- 0x40b050, 0xb05040, 0x5040b0, 0x4050b0, 0xb04050, 0x50b040, 0x405000,
- 0x504000, 0x500040, 0x400050, 0x005040, 0x004050, 0x405040, 0x504040,
- 0x404050, 0x504050, 0x405050, 0x505040, 0xe06050, 0x6050e0, 0x50e060,
- 0xe05060, 0x60e050, 0x5060e0, 0xe0a050, 0xa050e0, 0x50e0a0, 0xe050a0,
- 0xa0e050, 0x50a0e0, 0xe02050, 0x2050e0, 0x50e020, 0xe05020, 0x20e050,
- 0x5020e0, 0xe0f050, 0xf050e0, 0x50e0f0, 0xe050f0, 0xf0e050, 0x50f0e0,
- 0xe0b050, 0xb050e0, 0x50e0b0, 0xe050b0, 0xb0e050, 0x50b0e0, 0xe05000,
- 0x50e000, 0x5000e0, 0xe00050, 0x0050e0, 0x00e050, 0xe050e0, 0x50e0e0,
- 0xe0e050, 0x50e050, 0xe05050, 0x5050e0, 0x60a050, 0xa05060, 0x5060a0,
- 0x6050a0, 0xa06050, 0x50a060, 0x602050, 0x205060, 0x506020, 0x605020,
- 0x206050, 0x502060, 0x60f050, 0xf05060, 0x5060f0, 0x6050f0, 0xf06050,
- 0x50f060, 0x60b050, 0xb05060, 0x5060b0, 0x6050b0, 0xb06050, 0x50b060,
- 0x605000, 0x506000, 0x500060, 0x600050, 0x005060, 0x006050, 0x605060,
- 0x506060, 0x606050, 0x506050, 0x605050, 0x505060, 0xa02050, 0x2050a0,
- 0x50a020, 0xa05020, 0x20a050, 0x5020a0, 0xa0f050, 0xf050a0, 0x50a0f0,
- 0xa050f0, 0xf0a050, 0x50f0a0, 0xa0b050, 0xb050a0, 0x50a0b0, 0xa050b0,
- 0xb0a050, 0x50b0a0, 0xa05000, 0x50a000, 0x5000a0, 0xa00050, 0x0050a0,
- 0x00a050, 0xa050a0, 0x50a0a0, 0xa0a050, 0x50a050, 0xa05050, 0x5050a0,
- 0x20f050, 0xf05020, 0x5020f0, 0x2050f0, 0xf02050, 0x50f020, 0x20b050,
- 0xb05020, 0x5020b0, 0x2050b0, 0xb02050, 0x50b020, 0x205000, 0x502000,
- 0x500020, 0x200050, 0x005020, 0x002050, 0x205020, 0x502020, 0x202050,
- 0x502050, 0x205050, 0x505020, 0xf0b050, 0xb050f0, 0x50f0b0, 0xf050b0,
- 0xb0f050, 0x50b0f0, 0xf05000, 0x50f000, 0x5000f0, 0xf00050, 0x0050f0,
- 0x00f050, 0xf050f0, 0x50f0f0, 0xf0f050, 0x50f050, 0xf05050, 0x5050f0,
- 0xb05000, 0x50b000, 0x5000b0, 0xb00050, 0x0050b0, 0x00b050, 0xb050b0,
- 0x50b0b0, 0xb0b050, 0x50b050, 0xb05050, 0x5050b0, 0x505050, 0x500000,
- 0x005000, 0x000050, 0x505000, 0x500050, 0x005050, 0xff80d0, 0x80d0ff,
- 0xd0ff80, 0xffd080, 0x80ffd0, 0xd080ff, 0xffc0d0, 0xc0d0ff, 0xd0ffc0,
- 0xffd0c0, 0xc0ffd0, 0xd0c0ff, 0xff40d0, 0x40d0ff, 0xd0ff40, 0xffd040,
- 0x40ffd0, 0xd040ff, 0xffe0d0, 0xe0d0ff, 0xd0ffe0, 0xffd0e0, 0xe0ffd0,
- 0xd0e0ff, 0xff60d0, 0x60d0ff, 0xd0ff60, 0xffd060, 0x60ffd0, 0xd060ff,
- 0xffa0d0, 0xa0d0ff, 0xd0ffa0, 0xffd0a0, 0xa0ffd0, 0xd0a0ff, 0xff20d0,
- 0x20d0ff, 0xd0ff20, 0xffd020, 0x20ffd0, 0xd020ff, 0xfff0d0, 0xf0d0ff,
- 0xd0fff0, 0xffd0f0, 0xf0ffd0, 0xd0f0ff, 0xffb0d0, 0xb0d0ff, 0xd0ffb0,
- 0xffd0b0, 0xb0ffd0, 0xd0b0ff, 0xff50d0, 0x50d0ff, 0xd0ff50, 0xffd050,
- 0x50ffd0, 0xd050ff, 0xffd000, 0xd0ff00, 0xd000ff, 0xff00d0, 0x00d0ff,
- 0x00ffd0, 0xffd0ff, 0xd0ffff, 0xffffd0, 0xd0ffd0, 0xffd0d0, 0xd0d0ff,
- 0x80c0d0, 0xc0d080, 0xd080c0, 0x80d0c0, 0xc080d0, 0xd0c080, 0x8040d0,
- 0x40d080, 0xd08040, 0x80d040, 0x4080d0, 0xd04080, 0x80e0d0, 0xe0d080,
- 0xd080e0, 0x80d0e0, 0xe080d0, 0xd0e080, 0x8060d0, 0x60d080, 0xd08060,
- 0x80d060, 0x6080d0, 0xd06080, 0x80a0d0, 0xa0d080, 0xd080a0, 0x80d0a0,
- 0xa080d0, 0xd0a080, 0x8020d0, 0x20d080, 0xd08020, 0x80d020, 0x2080d0,
- 0xd02080, 0x80f0d0, 0xf0d080, 0xd080f0, 0x80d0f0, 0xf080d0, 0xd0f080,
- 0x80b0d0, 0xb0d080, 0xd080b0, 0x80d0b0, 0xb080d0, 0xd0b080, 0x8050d0,
- 0x50d080, 0xd08050, 0x80d050, 0x5080d0, 0xd05080, 0x80d000, 0xd08000,
- 0xd00080, 0x8000d0, 0x00d080, 0x0080d0, 0x80d080, 0xd08080, 0x8080d0,
- 0xd080d0, 0x80d0d0, 0xd0d080, 0xc040d0, 0x40d0c0, 0xd0c040, 0xc0d040,
- 0x40c0d0, 0xd040c0, 0xc0e0d0, 0xe0d0c0, 0xd0c0e0, 0xc0d0e0, 0xe0c0d0,
- 0xd0e0c0, 0xc060d0, 0x60d0c0, 0xd0c060, 0xc0d060, 0x60c0d0, 0xd060c0,
- 0xc0a0d0, 0xa0d0c0, 0xd0c0a0, 0xc0d0a0, 0xa0c0d0, 0xd0a0c0, 0xc020d0,
- 0x20d0c0, 0xd0c020, 0xc0d020, 0x20c0d0, 0xd020c0, 0xc0f0d0, 0xf0d0c0,
- 0xd0c0f0, 0xc0d0f0, 0xf0c0d0, 0xd0f0c0, 0xc0b0d0, 0xb0d0c0, 0xd0c0b0,
- 0xc0d0b0, 0xb0c0d0, 0xd0b0c0, 0xc050d0, 0x50d0c0, 0xd0c050, 0xc0d050,
- 0x50c0d0, 0xd050c0, 0xc0d000, 0xd0c000, 0xd000c0, 0xc000d0, 0x00d0c0,
- 0x00c0d0, 0xc0d0c0, 0xd0c0c0, 0xc0c0d0, 0xd0c0d0, 0xc0d0d0, 0xd0d0c0,
- 0x40e0d0, 0xe0d040, 0xd040e0, 0x40d0e0, 0xe040d0, 0xd0e040, 0x4060d0,
- 0x60d040, 0xd04060, 0x40d060, 0x6040d0, 0xd06040, 0x40a0d0, 0xa0d040,
- 0xd040a0, 0x40d0a0, 0xa040d0, 0xd0a040, 0x4020d0, 0x20d040, 0xd04020,
- 0x40d020, 0x2040d0, 0xd02040, 0x40f0d0, 0xf0d040, 0xd040f0, 0x40d0f0,
- 0xf040d0, 0xd0f040, 0x40b0d0, 0xb0d040, 0xd040b0, 0x40d0b0, 0xb040d0,
- 0xd0b040, 0x4050d0, 0x50d040, 0xd04050, 0x40d050, 0x5040d0, 0xd05040,
- 0x40d000, 0xd04000, 0xd00040, 0x4000d0, 0x00d040, 0x0040d0, 0x40d040,
- 0xd04040, 0x4040d0, 0xd040d0, 0x40d0d0, 0xd0d040, 0xe060d0, 0x60d0e0,
- 0xd0e060, 0xe0d060, 0x60e0d0, 0xd060e0, 0xe0a0d0, 0xa0d0e0, 0xd0e0a0,
- 0xe0d0a0, 0xa0e0d0, 0xd0a0e0, 0xe020d0, 0x20d0e0, 0xd0e020, 0xe0d020,
- 0x20e0d0, 0xd020e0, 0xe0f0d0, 0xf0d0e0, 0xd0e0f0, 0xe0d0f0, 0xf0e0d0,
- 0xd0f0e0, 0xe0b0d0, 0xb0d0e0, 0xd0e0b0, 0xe0d0b0, 0xb0e0d0, 0xd0b0e0,
- 0xe050d0, 0x50d0e0, 0xd0e050, 0xe0d050, 0x50e0d0, 0xd050e0, 0xe0d000,
- 0xd0e000, 0xd000e0, 0xe000d0, 0x00d0e0, 0x00e0d0, 0xe0d0e0, 0xd0e0e0,
- 0xe0e0d0, 0xd0e0d0, 0xe0d0d0, 0xd0d0e0, 0x60a0d0, 0xa0d060, 0xd060a0,
- 0x60d0a0, 0xa060d0, 0xd0a060, 0x6020d0, 0x20d060, 0xd06020, 0x60d020,
- 0x2060d0, 0xd02060, 0x60f0d0, 0xf0d060, 0xd060f0, 0x60d0f0, 0xf060d0,
- 0xd0f060, 0x60b0d0, 0xb0d060, 0xd060b0, 0x60d0b0, 0xb060d0, 0xd0b060,
- 0x6050d0, 0x50d060, 0xd06050, 0x60d050, 0x5060d0, 0xd05060, 0x60d000,
- 0xd06000, 0xd00060, 0x6000d0, 0x00d060, 0x0060d0, 0x60d060, 0xd06060,
- 0x6060d0, 0xd060d0, 0x60d0d0, 0xd0d060, 0xa020d0, 0x20d0a0, 0xd0a020,
- 0xa0d020, 0x20a0d0, 0xd020a0, 0xa0f0d0, 0xf0d0a0, 0xd0a0f0, 0xa0d0f0,
- 0xf0a0d0, 0xd0f0a0, 0xa0b0d0, 0xb0d0a0, 0xd0a0b0, 0xa0d0b0, 0xb0a0d0,
- 0xd0b0a0, 0xa050d0, 0x50d0a0, 0xd0a050, 0xa0d050, 0x50a0d0, 0xd050a0,
- 0xa0d000, 0xd0a000, 0xd000a0, 0xa000d0, 0x00d0a0, 0x00a0d0, 0xa0d0a0,
- 0xd0a0a0, 0xa0a0d0, 0xd0a0d0, 0xa0d0d0, 0xd0d0a0, 0x20f0d0, 0xf0d020,
- 0xd020f0, 0x20d0f0, 0xf020d0, 0xd0f020, 0x20b0d0, 0xb0d020, 0xd020b0,
- 0x20d0b0, 0xb020d0, 0xd0b020, 0x2050d0, 0x50d020, 0xd02050, 0x20d050,
- 0x5020d0, 0xd05020, 0x20d000, 0xd02000, 0xd00020, 0x2000d0, 0x00d020,
- 0x0020d0, 0x20d020, 0xd02020, 0x2020d0, 0xd020d0, 0x20d0d0, 0xd0d020,
- 0xf0b0d0, 0xb0d0f0, 0xd0f0b0, 0xf0d0b0, 0xb0f0d0, 0xd0b0f0, 0xf050d0,
- 0x50d0f0, 0xd0f050, 0xf0d050, 0x50f0d0, 0xd050f0, 0xf0d000, 0xd0f000,
- 0xd000f0, 0xf000d0, 0x00d0f0, 0x00f0d0, 0xf0d0f0, 0xd0f0f0, 0xf0f0d0,
- 0xd0f0d0, 0xf0d0d0, 0xd0d0f0, 0xb050d0, 0x50d0b0, 0xd0b050, 0xb0d050,
- 0x50b0d0, 0xd050b0, 0xb0d000, 0xd0b000, 0xd000b0, 0xb000d0, 0x00d0b0,
- 0x00b0d0, 0xb0d0b0, 0xd0b0b0, 0xb0b0d0, 0xd0b0d0, 0xb0d0d0, 0xd0d0b0,
- 0x50d000, 0xd05000, 0xd00050, 0x5000d0, 0x00d050, 0x0050d0, 0x50d050,
- 0xd05050, 0x5050d0, 0xd050d0, 0x50d0d0, 0xd0d050, 0xd0d0d0, 0xd00000,
- 0x00d000, 0x0000d0, 0xd0d000, 0xd000d0, 0x00d0d0, 0xff8070, 0x8070ff,
- 0x70ff80, 0xff7080, 0x80ff70, 0x7080ff, 0xffc070, 0xc070ff, 0x70ffc0,
- 0xff70c0, 0xc0ff70, 0x70c0ff, 0xff4070, 0x4070ff, 0x70ff40, 0xff7040,
- 0x40ff70, 0x7040ff, 0xffe070, 0xe070ff, 0x70ffe0, 0xff70e0, 0xe0ff70,
- 0x70e0ff, 0xff6070, 0x6070ff, 0x70ff60, 0xff7060, 0x60ff70, 0x7060ff,
- 0xffa070, 0xa070ff, 0x70ffa0, 0xff70a0, 0xa0ff70, 0x70a0ff, 0xff2070,
- 0x2070ff, 0x70ff20, 0xff7020, 0x20ff70, 0x7020ff, 0xfff070, 0xf070ff,
- 0x70fff0, 0xff70f0, 0xf0ff70, 0x70f0ff, 0xffb070, 0xb070ff, 0x70ffb0,
- 0xff70b0, 0xb0ff70, 0x70b0ff, 0xff5070, 0x5070ff, 0x70ff50, 0xff7050,
- 0x50ff70, 0x7050ff, 0xffd070, 0xd070ff, 0x70ffd0, 0xff70d0, 0xd0ff70,
- 0x70d0ff, 0xff7000, 0x70ff00, 0x7000ff, 0xff0070, 0x0070ff, 0x00ff70,
- 0xff70ff, 0x70ffff, 0xffff70, 0x70ff70, 0xff7070, 0x7070ff, 0x80c070,
- 0xc07080, 0x7080c0, 0x8070c0, 0xc08070, 0x70c080, 0x804070, 0x407080,
- 0x708040, 0x807040, 0x408070, 0x704080, 0x80e070, 0xe07080, 0x7080e0,
- 0x8070e0, 0xe08070, 0x70e080, 0x806070, 0x607080, 0x708060, 0x807060,
- 0x608070, 0x706080, 0x80a070, 0xa07080, 0x7080a0, 0x8070a0, 0xa08070,
- 0x70a080, 0x802070, 0x207080, 0x708020, 0x807020, 0x208070, 0x702080,
- 0x80f070, 0xf07080, 0x7080f0, 0x8070f0, 0xf08070, 0x70f080, 0x80b070,
- 0xb07080, 0x7080b0, 0x8070b0, 0xb08070, 0x70b080, 0x805070, 0x507080,
- 0x708050, 0x807050, 0x508070, 0x705080, 0x80d070, 0xd07080, 0x7080d0,
- 0x8070d0, 0xd08070, 0x70d080, 0x807000, 0x708000, 0x700080, 0x800070,
- 0x007080, 0x008070, 0x807080, 0x708080, 0x808070, 0x708070, 0x807070,
- 0x707080, 0xc04070, 0x4070c0, 0x70c040, 0xc07040, 0x40c070, 0x7040c0,
- 0xc0e070, 0xe070c0, 0x70c0e0, 0xc070e0, 0xe0c070, 0x70e0c0, 0xc06070,
- 0x6070c0, 0x70c060, 0xc07060, 0x60c070, 0x7060c0, 0xc0a070, 0xa070c0,
- 0x70c0a0, 0xc070a0, 0xa0c070, 0x70a0c0, 0xc02070, 0x2070c0, 0x70c020,
- 0xc07020, 0x20c070, 0x7020c0, 0xc0f070, 0xf070c0, 0x70c0f0, 0xc070f0,
- 0xf0c070, 0x70f0c0, 0xc0b070, 0xb070c0, 0x70c0b0, 0xc070b0, 0xb0c070,
- 0x70b0c0, 0xc05070, 0x5070c0, 0x70c050, 0xc07050, 0x50c070, 0x7050c0,
- 0xc0d070, 0xd070c0, 0x70c0d0, 0xc070d0, 0xd0c070, 0x70d0c0, 0xc07000,
- 0x70c000, 0x7000c0, 0xc00070, 0x0070c0, 0x00c070, 0xc070c0, 0x70c0c0,
- 0xc0c070, 0x70c070, 0xc07070, 0x7070c0, 0x40e070, 0xe07040, 0x7040e0,
- 0x4070e0, 0xe04070, 0x70e040, 0x406070, 0x607040, 0x704060, 0x407060,
- 0x604070, 0x706040, 0x40a070, 0xa07040, 0x7040a0, 0x4070a0, 0xa04070,
- 0x70a040, 0x402070, 0x207040, 0x704020, 0x407020, 0x204070, 0x702040,
- 0x40f070, 0xf07040, 0x7040f0, 0x4070f0, 0xf04070, 0x70f040, 0x40b070,
- 0xb07040, 0x7040b0, 0x4070b0, 0xb04070, 0x70b040, 0x405070, 0x507040,
- 0x704050, 0x407050, 0x504070, 0x705040, 0x40d070, 0xd07040, 0x7040d0,
- 0x4070d0, 0xd04070, 0x70d040, 0x407000, 0x704000, 0x700040, 0x400070,
- 0x007040, 0x004070, 0x407040, 0x704040, 0x404070, 0x704070, 0x407070,
- 0x707040, 0xe06070, 0x6070e0, 0x70e060, 0xe07060, 0x60e070, 0x7060e0,
- 0xe0a070, 0xa070e0, 0x70e0a0, 0xe070a0, 0xa0e070, 0x70a0e0, 0xe02070,
- 0x2070e0, 0x70e020, 0xe07020, 0x20e070, 0x7020e0, 0xe0f070, 0xf070e0,
- 0x70e0f0, 0xe070f0, 0xf0e070, 0x70f0e0, 0xe0b070, 0xb070e0, 0x70e0b0,
- 0xe070b0, 0xb0e070, 0x70b0e0, 0xe05070, 0x5070e0, 0x70e050, 0xe07050,
- 0x50e070, 0x7050e0, 0xe0d070, 0xd070e0, 0x70e0d0, 0xe070d0, 0xd0e070,
- 0x70d0e0, 0xe07000, 0x70e000, 0x7000e0, 0xe00070, 0x0070e0, 0x00e070,
- 0xe070e0, 0x70e0e0, 0xe0e070, 0x70e070, 0xe07070, 0x7070e0, 0x60a070,
- 0xa07060, 0x7060a0, 0x6070a0, 0xa06070, 0x70a060, 0x602070, 0x207060,
- 0x706020, 0x607020, 0x206070, 0x702060, 0x60f070, 0xf07060, 0x7060f0,
- 0x6070f0, 0xf06070, 0x70f060, 0x60b070, 0xb07060, 0x7060b0, 0x6070b0,
- 0xb06070, 0x70b060, 0x605070, 0x507060, 0x706050, 0x607050, 0x506070,
- 0x705060, 0x60d070, 0xd07060, 0x7060d0, 0x6070d0, 0xd06070, 0x70d060,
- 0x607000, 0x706000, 0x700060, 0x600070, 0x007060, 0x006070, 0x607060,
- 0x706060, 0x606070, 0x706070, 0x607070, 0x707060, 0xa02070, 0x2070a0,
- 0x70a020, 0xa07020, 0x20a070, 0x7020a0, 0xa0f070, 0xf070a0, 0x70a0f0,
- 0xa070f0, 0xf0a070, 0x70f0a0, 0xa0b070, 0xb070a0, 0x70a0b0, 0xa070b0,
- 0xb0a070, 0x70b0a0, 0xa05070, 0x5070a0, 0x70a050, 0xa07050, 0x50a070,
- 0x7050a0, 0xa0d070, 0xd070a0, 0x70a0d0, 0xa070d0, 0xd0a070, 0x70d0a0,
- 0xa07000, 0x70a000, 0x7000a0, 0xa00070, 0x0070a0, 0x00a070, 0xa070a0,
- 0x70a0a0, 0xa0a070, 0x70a070, 0xa07070, 0x7070a0, 0x20f070, 0xf07020,
- 0x7020f0, 0x2070f0, 0xf02070, 0x70f020, 0x20b070, 0xb07020, 0x7020b0,
- 0x2070b0, 0xb02070, 0x70b020, 0x205070, 0x507020, 0x702050, 0x207050,
- 0x502070, 0x705020, 0x20d070, 0xd07020, 0x7020d0, 0x2070d0, 0xd02070,
- 0x70d020, 0x207000, 0x702000, 0x700020, 0x200070, 0x007020, 0x002070,
- 0x207020, 0x702020, 0x202070, 0x702070, 0x207070, 0x707020, 0xf0b070,
- 0xb070f0, 0x70f0b0, 0xf070b0, 0xb0f070, 0x70b0f0, 0xf05070, 0x5070f0,
- 0x70f050, 0xf07050, 0x50f070, 0x7050f0, 0xf0d070, 0xd070f0, 0x70f0d0,
- 0xf070d0, 0xd0f070, 0x70d0f0, 0xf07000, 0x70f000, 0x7000f0, 0xf00070,
- 0x0070f0, 0x00f070, 0xf070f0, 0x70f0f0, 0xf0f070, 0x70f070, 0xf07070,
- 0x7070f0, 0xb05070, 0x5070b0, 0x70b050, 0xb07050, 0x50b070, 0x7050b0,
- 0xb0d070, 0xd070b0, 0x70b0d0, 0xb070d0, 0xd0b070, 0x70d0b0, 0xb07000,
- 0x70b000, 0x7000b0, 0xb00070, 0x0070b0, 0x00b070, 0xb070b0, 0x70b0b0,
- 0xb0b070, 0x70b070, 0xb07070, 0x7070b0, 0x50d070, 0xd07050, 0x7050d0,
- 0x5070d0, 0xd05070, 0x70d050, 0x507000, 0x705000, 0x700050, 0x500070,
- 0x007050, 0x005070, 0x507050, 0x705050, 0x505070, 0x705070, 0x507070,
- 0x707050, 0xd07000, 0x70d000, 0x7000d0, 0xd00070, 0x0070d0, 0x00d070,
- 0xd070d0, 0x70d0d0, 0xd0d070, 0x70d070, 0xd07070, 0x7070d0, 0x707070,
- 0x700000, 0x007000, 0x000070, 0x707000, 0x700070, 0x007070, 0xff8030,
- 0x8030ff, 0x30ff80, 0xff3080, 0x80ff30, 0x3080ff, 0xffc030, 0xc030ff,
- 0x30ffc0, 0xff30c0, 0xc0ff30, 0x30c0ff, 0xff4030, 0x4030ff, 0x30ff40,
- 0xff3040, 0x40ff30, 0x3040ff, 0xffe030, 0xe030ff, 0x30ffe0, 0xff30e0,
- 0xe0ff30, 0x30e0ff, 0xff6030, 0x6030ff, 0x30ff60, 0xff3060, 0x60ff30,
- 0x3060ff, 0xffa030, 0xa030ff, 0x30ffa0, 0xff30a0, 0xa0ff30, 0x30a0ff,
- 0xff2030, 0x2030ff, 0x30ff20, 0xff3020, 0x20ff30, 0x3020ff, 0xfff030,
- 0xf030ff, 0x30fff0, 0xff30f0, 0xf0ff30, 0x30f0ff, 0xffb030, 0xb030ff,
- 0x30ffb0, 0xff30b0, 0xb0ff30, 0x30b0ff, 0xff5030, 0x5030ff, 0x30ff50,
- 0xff3050, 0x50ff30, 0x3050ff, 0xffd030, 0xd030ff, 0x30ffd0, 0xff30d0,
- 0xd0ff30, 0x30d0ff, 0xff7030, 0x7030ff, 0x30ff70, 0xff3070, 0x70ff30,
- 0x3070ff, 0xff3000, 0x30ff00, 0x3000ff, 0xff0030, 0x0030ff, 0x00ff30,
- 0xff30ff, 0x30ffff, 0xffff30, 0x30ff30, 0xff3030, 0x3030ff, 0x80c030,
- 0xc03080, 0x3080c0, 0x8030c0, 0xc08030, 0x30c080, 0x804030, 0x403080,
- 0x308040, 0x803040, 0x408030, 0x304080, 0x80e030, 0xe03080, 0x3080e0,
- 0x8030e0, 0xe08030, 0x30e080, 0x806030, 0x603080, 0x308060, 0x803060,
- 0x608030, 0x306080, 0x80a030, 0xa03080, 0x3080a0, 0x8030a0, 0xa08030,
- 0x30a080, 0x802030, 0x203080, 0x308020, 0x803020, 0x208030, 0x302080,
- 0x80f030, 0xf03080, 0x3080f0, 0x8030f0, 0xf08030, 0x30f080, 0x80b030,
- 0xb03080, 0x3080b0, 0x8030b0, 0xb08030, 0x30b080, 0x805030, 0x503080,
- 0x308050, 0x803050, 0x508030, 0x305080, 0x80d030, 0xd03080, 0x3080d0,
- 0x8030d0, 0xd08030, 0x30d080, 0x807030, 0x703080, 0x308070, 0x803070,
- 0x708030, 0x307080, 0x803000, 0x308000, 0x300080, 0x800030, 0x003080,
- 0x008030, 0x803080, 0x308080, 0x808030, 0x308030, 0x803030, 0x303080,
- 0xc04030, 0x4030c0, 0x30c040, 0xc03040, 0x40c030, 0x3040c0, 0xc0e030,
- 0xe030c0, 0x30c0e0, 0xc030e0, 0xe0c030, 0x30e0c0, 0xc06030, 0x6030c0,
- 0x30c060, 0xc03060, 0x60c030, 0x3060c0, 0xc0a030, 0xa030c0, 0x30c0a0,
- 0xc030a0, 0xa0c030, 0x30a0c0, 0xc02030, 0x2030c0, 0x30c020, 0xc03020,
- 0x20c030, 0x3020c0, 0xc0f030, 0xf030c0, 0x30c0f0, 0xc030f0, 0xf0c030,
- 0x30f0c0, 0xc0b030, 0xb030c0, 0x30c0b0, 0xc030b0, 0xb0c030, 0x30b0c0,
- 0xc05030, 0x5030c0, 0x30c050, 0xc03050, 0x50c030, 0x3050c0, 0xc0d030,
- 0xd030c0, 0x30c0d0, 0xc030d0, 0xd0c030, 0x30d0c0, 0xc07030, 0x7030c0,
- 0x30c070, 0xc03070, 0x70c030, 0x3070c0, 0xc03000, 0x30c000, 0x3000c0,
- 0xc00030, 0x0030c0, 0x00c030, 0xc030c0, 0x30c0c0, 0xc0c030, 0x30c030,
- 0xc03030, 0x3030c0, 0x40e030, 0xe03040, 0x3040e0, 0x4030e0, 0xe04030,
- 0x30e040, 0x406030, 0x603040, 0x304060, 0x403060, 0x604030, 0x306040,
- 0x40a030, 0xa03040, 0x3040a0, 0x4030a0, 0xa04030, 0x30a040, 0x402030,
- 0x203040, 0x304020, 0x403020, 0x204030, 0x302040, 0x40f030, 0xf03040,
- 0x3040f0, 0x4030f0, 0xf04030, 0x30f040, 0x40b030, 0xb03040, 0x3040b0,
- 0x4030b0, 0xb04030, 0x30b040, 0x405030, 0x503040, 0x304050, 0x403050,
- 0x504030, 0x305040, 0x40d030, 0xd03040, 0x3040d0, 0x4030d0, 0xd04030,
- 0x30d040, 0x407030, 0x703040, 0x304070, 0x403070, 0x704030, 0x307040,
- 0x403000, 0x304000, 0x300040, 0x400030, 0x003040, 0x004030, 0x403040,
- 0x304040, 0x404030, 0x304030, 0x403030, 0x303040, 0xe06030, 0x6030e0,
- 0x30e060, 0xe03060, 0x60e030, 0x3060e0, 0xe0a030, 0xa030e0, 0x30e0a0,
- 0xe030a0, 0xa0e030, 0x30a0e0, 0xe02030, 0x2030e0, 0x30e020, 0xe03020,
- 0x20e030, 0x3020e0, 0xe0f030, 0xf030e0, 0x30e0f0, 0xe030f0, 0xf0e030,
- 0x30f0e0, 0xe0b030, 0xb030e0, 0x30e0b0, 0xe030b0, 0xb0e030, 0x30b0e0,
- 0xe05030, 0x5030e0, 0x30e050, 0xe03050, 0x50e030, 0x3050e0, 0xe0d030,
- 0xd030e0, 0x30e0d0, 0xe030d0, 0xd0e030, 0x30d0e0, 0xe07030, 0x7030e0,
- 0x30e070, 0xe03070, 0x70e030, 0x3070e0, 0xe03000, 0x30e000, 0x3000e0,
- 0xe00030, 0x0030e0, 0x00e030, 0xe030e0, 0x30e0e0, 0xe0e030, 0x30e030,
- 0xe03030, 0x3030e0, 0x60a030, 0xa03060, 0x3060a0, 0x6030a0, 0xa06030,
- 0x30a060, 0x602030, 0x203060, 0x306020, 0x603020, 0x206030, 0x302060,
- 0x60f030, 0xf03060, 0x3060f0, 0x6030f0, 0xf06030, 0x30f060, 0x60b030,
- 0xb03060, 0x3060b0, 0x6030b0, 0xb06030, 0x30b060, 0x605030, 0x503060,
- 0x306050, 0x603050, 0x506030, 0x305060, 0x60d030, 0xd03060, 0x3060d0,
- 0x6030d0, 0xd06030, 0x30d060, 0x607030, 0x703060, 0x306070, 0x603070,
- 0x706030, 0x307060, 0x603000, 0x306000, 0x300060, 0x600030, 0x003060,
- 0x006030, 0x603060, 0x306060, 0x606030, 0x306030, 0x603030, 0x303060,
- 0xa02030, 0x2030a0, 0x30a020, 0xa03020, 0x20a030, 0x3020a0, 0xa0f030,
- 0xf030a0, 0x30a0f0, 0xa030f0, 0xf0a030, 0x30f0a0, 0xa0b030, 0xb030a0,
- 0x30a0b0, 0xa030b0, 0xb0a030, 0x30b0a0, 0xa05030, 0x5030a0, 0x30a050,
- 0xa03050, 0x50a030, 0x3050a0, 0xa0d030, 0xd030a0, 0x30a0d0, 0xa030d0,
- 0xd0a030, 0x30d0a0, 0xa07030, 0x7030a0, 0x30a070, 0xa03070, 0x70a030,
- 0x3070a0, 0xa03000, 0x30a000, 0x3000a0, 0xa00030, 0x0030a0, 0x00a030,
- 0xa030a0, 0x30a0a0, 0xa0a030, 0x30a030, 0xa03030, 0x3030a0, 0x20f030,
- 0xf03020, 0x3020f0, 0x2030f0, 0xf02030, 0x30f020, 0x20b030, 0xb03020,
- 0x3020b0, 0x2030b0, 0xb02030, 0x30b020, 0x205030, 0x503020, 0x302050,
- 0x203050, 0x502030, 0x305020, 0x20d030, 0xd03020, 0x3020d0, 0x2030d0,
- 0xd02030, 0x30d020, 0x207030, 0x703020, 0x302070, 0x203070, 0x702030,
- 0x307020, 0x203000, 0x302000, 0x300020, 0x200030, 0x003020, 0x002030,
- 0x203020, 0x302020, 0x202030, 0x302030, 0x203030, 0x303020, 0xf0b030,
- 0xb030f0, 0x30f0b0, 0xf030b0, 0xb0f030, 0x30b0f0, 0xf05030, 0x5030f0,
- 0x30f050, 0xf03050, 0x50f030, 0x3050f0, 0xf0d030, 0xd030f0, 0x30f0d0,
- 0xf030d0, 0xd0f030, 0x30d0f0, 0xf07030, 0x7030f0, 0x30f070, 0xf03070,
- 0x70f030, 0x3070f0, 0xf03000, 0x30f000, 0x3000f0, 0xf00030, 0x0030f0,
- 0x00f030, 0xf030f0, 0x30f0f0, 0xf0f030, 0x30f030, 0xf03030, 0x3030f0,
- 0xb05030, 0x5030b0, 0x30b050, 0xb03050, 0x50b030, 0x3050b0, 0xb0d030,
- 0xd030b0, 0x30b0d0, 0xb030d0, 0xd0b030, 0x30d0b0, 0xb07030, 0x7030b0,
- 0x30b070, 0xb03070, 0x70b030, 0x3070b0, 0xb03000, 0x30b000, 0x3000b0,
- 0xb00030, 0x0030b0, 0x00b030, 0xb030b0, 0x30b0b0, 0xb0b030, 0x30b030,
- 0xb03030, 0x3030b0, 0x50d030, 0xd03050, 0x3050d0, 0x5030d0, 0xd05030,
- 0x30d050, 0x507030, 0x703050, 0x305070, 0x503070, 0x705030, 0x307050,
- 0x503000, 0x305000, 0x300050, 0x500030, 0x003050, 0x005030, 0x503050,
- 0x305050, 0x505030, 0x305030, 0x503030, 0x303050, 0xd07030, 0x7030d0,
- 0x30d070, 0xd03070, 0x70d030, 0x3070d0, 0xd03000, 0x30d000, 0x3000d0,
- 0xd00030, 0x0030d0, 0x00d030, 0xd030d0, 0x30d0d0, 0xd0d030, 0x30d030,
- 0xd03030, 0x3030d0, 0x703000, 0x307000, 0x300070, 0x700030, 0x003070,
- 0x007030, 0x703070, 0x307070, 0x707030, 0x307030, 0x703030, 0x303070,
- 0x303030, 0x300000, 0x003000, 0x000030, 0x303000, 0x300030, 0x003030,
- 0xff8090, 0x8090ff, 0x90ff80, 0xff9080, 0x80ff90, 0x9080ff, 0xffc090,
- 0xc090ff, 0x90ffc0, 0xff90c0, 0xc0ff90, 0x90c0ff, 0xff4090, 0x4090ff,
- 0x90ff40, 0xff9040, 0x40ff90, 0x9040ff, 0xffe090, 0xe090ff, 0x90ffe0,
- 0xff90e0, 0xe0ff90, 0x90e0ff, 0xff6090, 0x6090ff, 0x90ff60, 0xff9060,
- 0x60ff90, 0x9060ff, 0xffa090, 0xa090ff, 0x90ffa0, 0xff90a0, 0xa0ff90,
- 0x90a0ff, 0xff2090, 0x2090ff, 0x90ff20, 0xff9020, 0x20ff90, 0x9020ff,
- 0xfff090, 0xf090ff, 0x90fff0, 0xff90f0, 0xf0ff90, 0x90f0ff, 0xffb090,
- 0xb090ff, 0x90ffb0, 0xff90b0, 0xb0ff90, 0x90b0ff, 0xff5090, 0x5090ff,
- 0x90ff50, 0xff9050, 0x50ff90, 0x9050ff, 0xffd090, 0xd090ff, 0x90ffd0,
- 0xff90d0, 0xd0ff90, 0x90d0ff, 0xff7090, 0x7090ff, 0x90ff70, 0xff9070,
- 0x70ff90, 0x9070ff, 0xff3090, 0x3090ff, 0x90ff30, 0xff9030, 0x30ff90,
- 0x9030ff, 0xff9000, 0x90ff00, 0x9000ff, 0xff0090, 0x0090ff, 0x00ff90,
- 0xff90ff, 0x90ffff, 0xffff90, 0x90ff90, 0xff9090, 0x9090ff, 0x80c090,
- 0xc09080, 0x9080c0, 0x8090c0, 0xc08090, 0x90c080, 0x804090, 0x409080,
- 0x908040, 0x809040, 0x408090, 0x904080, 0x80e090, 0xe09080, 0x9080e0,
- 0x8090e0, 0xe08090, 0x90e080, 0x806090, 0x609080, 0x908060, 0x809060,
- 0x608090, 0x906080, 0x80a090, 0xa09080, 0x9080a0, 0x8090a0, 0xa08090,
- 0x90a080, 0x802090, 0x209080, 0x908020, 0x809020, 0x208090, 0x902080,
- 0x80f090, 0xf09080, 0x9080f0, 0x8090f0, 0xf08090, 0x90f080, 0x80b090,
- 0xb09080, 0x9080b0, 0x8090b0, 0xb08090, 0x90b080, 0x805090, 0x509080,
- 0x908050, 0x809050, 0x508090, 0x905080, 0x80d090, 0xd09080, 0x9080d0,
- 0x8090d0, 0xd08090, 0x90d080, 0x807090, 0x709080, 0x908070, 0x809070,
- 0x708090, 0x907080, 0x803090, 0x309080, 0x908030, 0x809030, 0x308090,
- 0x903080, 0x809000, 0x908000, 0x900080, 0x800090, 0x009080, 0x008090,
- 0x809080, 0x908080, 0x808090, 0x908090, 0x809090, 0x909080, 0xc04090,
- 0x4090c0, 0x90c040, 0xc09040, 0x40c090, 0x9040c0, 0xc0e090, 0xe090c0,
- 0x90c0e0, 0xc090e0, 0xe0c090, 0x90e0c0, 0xc06090, 0x6090c0, 0x90c060,
- 0xc09060, 0x60c090, 0x9060c0, 0xc0a090, 0xa090c0, 0x90c0a0, 0xc090a0,
- 0xa0c090, 0x90a0c0, 0xc02090, 0x2090c0, 0x90c020, 0xc09020, 0x20c090,
- 0x9020c0, 0xc0f090, 0xf090c0, 0x90c0f0, 0xc090f0, 0xf0c090, 0x90f0c0,
- 0xc0b090, 0xb090c0, 0x90c0b0, 0xc090b0, 0xb0c090, 0x90b0c0, 0xc05090,
- 0x5090c0, 0x90c050, 0xc09050, 0x50c090, 0x9050c0, 0xc0d090, 0xd090c0,
- 0x90c0d0, 0xc090d0, 0xd0c090, 0x90d0c0, 0xc07090, 0x7090c0, 0x90c070,
- 0xc09070, 0x70c090, 0x9070c0, 0xc03090, 0x3090c0, 0x90c030, 0xc09030,
- 0x30c090, 0x9030c0, 0xc09000, 0x90c000, 0x9000c0, 0xc00090, 0x0090c0,
- 0x00c090, 0xc090c0, 0x90c0c0, 0xc0c090, 0x90c090, 0xc09090, 0x9090c0,
- 0x40e090, 0xe09040, 0x9040e0, 0x4090e0, 0xe04090, 0x90e040, 0x406090,
- 0x609040, 0x904060, 0x409060, 0x604090, 0x906040, 0x40a090, 0xa09040,
- 0x9040a0, 0x4090a0, 0xa04090, 0x90a040, 0x402090, 0x209040, 0x904020,
- 0x409020, 0x204090, 0x902040, 0x40f090, 0xf09040, 0x9040f0, 0x4090f0,
- 0xf04090, 0x90f040, 0x40b090, 0xb09040, 0x9040b0, 0x4090b0, 0xb04090,
- 0x90b040, 0x405090, 0x509040, 0x904050, 0x409050, 0x504090, 0x905040,
- 0x40d090, 0xd09040, 0x9040d0, 0x4090d0, 0xd04090, 0x90d040, 0x407090,
- 0x709040, 0x904070, 0x409070, 0x704090, 0x907040, 0x403090, 0x309040,
- 0x904030, 0x409030, 0x304090, 0x903040, 0x409000, 0x904000, 0x900040,
- 0x400090, 0x009040, 0x004090, 0x409040, 0x904040, 0x404090, 0x904090,
- 0x409090, 0x909040, 0xe06090, 0x6090e0, 0x90e060, 0xe09060, 0x60e090,
- 0x9060e0, 0xe0a090, 0xa090e0, 0x90e0a0, 0xe090a0, 0xa0e090, 0x90a0e0,
- 0xe02090, 0x2090e0, 0x90e020, 0xe09020, 0x20e090, 0x9020e0, 0xe0f090,
- 0xf090e0, 0x90e0f0, 0xe090f0, 0xf0e090, 0x90f0e0, 0xe0b090, 0xb090e0,
- 0x90e0b0, 0xe090b0, 0xb0e090, 0x90b0e0, 0xe05090, 0x5090e0, 0x90e050,
- 0xe09050, 0x50e090, 0x9050e0, 0xe0d090, 0xd090e0, 0x90e0d0, 0xe090d0,
- 0xd0e090, 0x90d0e0, 0xe07090, 0x7090e0, 0x90e070, 0xe09070, 0x70e090,
- 0x9070e0, 0xe03090, 0x3090e0, 0x90e030, 0xe09030, 0x30e090, 0x9030e0,
- 0xe09000, 0x90e000, 0x9000e0, 0xe00090, 0x0090e0, 0x00e090, 0xe090e0,
- 0x90e0e0, 0xe0e090, 0x90e090, 0xe09090, 0x9090e0, 0x60a090, 0xa09060,
- 0x9060a0, 0x6090a0, 0xa06090, 0x90a060, 0x602090, 0x209060, 0x906020,
- 0x609020, 0x206090, 0x902060, 0x60f090, 0xf09060, 0x9060f0, 0x6090f0,
- 0xf06090, 0x90f060, 0x60b090, 0xb09060, 0x9060b0, 0x6090b0, 0xb06090,
- 0x90b060, 0x605090, 0x509060, 0x906050, 0x609050, 0x506090, 0x905060,
- 0x60d090, 0xd09060, 0x9060d0, 0x6090d0, 0xd06090, 0x90d060, 0x607090,
- 0x709060, 0x906070, 0x609070, 0x706090, 0x907060, 0x603090, 0x309060,
- 0x906030, 0x609030, 0x306090, 0x903060, 0x609000, 0x906000, 0x900060,
- 0x600090, 0x009060, 0x006090, 0x609060, 0x906060, 0x606090, 0x906090,
- 0x609090, 0x909060, 0xa02090, 0x2090a0, 0x90a020, 0xa09020, 0x20a090,
- 0x9020a0, 0xa0f090, 0xf090a0, 0x90a0f0, 0xa090f0, 0xf0a090, 0x90f0a0,
- 0xa0b090, 0xb090a0, 0x90a0b0, 0xa090b0, 0xb0a090, 0x90b0a0, 0xa05090,
- 0x5090a0, 0x90a050, 0xa09050, 0x50a090, 0x9050a0, 0xa0d090, 0xd090a0,
- 0x90a0d0, 0xa090d0, 0xd0a090, 0x90d0a0, 0xa07090, 0x7090a0, 0x90a070,
- 0xa09070, 0x70a090, 0x9070a0, 0xa03090, 0x3090a0, 0x90a030, 0xa09030,
- 0x30a090, 0x9030a0, 0xa09000, 0x90a000, 0x9000a0, 0xa00090, 0x0090a0,
- 0x00a090, 0xa090a0, 0x90a0a0, 0xa0a090, 0x90a090, 0xa09090, 0x9090a0,
- 0x20f090, 0xf09020, 0x9020f0, 0x2090f0, 0xf02090, 0x90f020, 0x20b090,
- 0xb09020, 0x9020b0, 0x2090b0, 0xb02090, 0x90b020, 0x205090, 0x509020,
- 0x902050, 0x209050, 0x502090, 0x905020, 0x20d090, 0xd09020, 0x9020d0,
- 0x2090d0, 0xd02090, 0x90d020, 0x207090, 0x709020, 0x902070, 0x209070,
- 0x702090, 0x907020, 0x203090, 0x309020, 0x902030, 0x209030, 0x302090,
- 0x903020, 0x209000, 0x902000, 0x900020, 0x200090, 0x009020, 0x002090,
- 0x209020, 0x902020, 0x202090, 0x902090, 0x209090, 0x909020, 0xf0b090,
- 0xb090f0, 0x90f0b0, 0xf090b0, 0xb0f090, 0x90b0f0, 0xf05090, 0x5090f0,
- 0x90f050, 0xf09050, 0x50f090, 0x9050f0, 0xf0d090, 0xd090f0, 0x90f0d0,
- 0xf090d0, 0xd0f090, 0x90d0f0, 0xf07090, 0x7090f0, 0x90f070, 0xf09070,
- 0x70f090, 0x9070f0, 0xf03090, 0x3090f0, 0x90f030, 0xf09030, 0x30f090,
- 0x9030f0, 0xf09000, 0x90f000, 0x9000f0, 0xf00090, 0x0090f0, 0x00f090,
- 0xf090f0, 0x90f0f0, 0xf0f090, 0x90f090, 0xf09090, 0x9090f0, 0xb05090,
- 0x5090b0, 0x90b050, 0xb09050, 0x50b090, 0x9050b0, 0xb0d090, 0xd090b0,
- 0x90b0d0, 0xb090d0, 0xd0b090, 0x90d0b0, 0xb07090, 0x7090b0, 0x90b070,
- 0xb09070, 0x70b090, 0x9070b0, 0xb03090, 0x3090b0, 0x90b030, 0xb09030,
- 0x30b090, 0x9030b0, 0xb09000, 0x90b000, 0x9000b0, 0xb00090, 0x0090b0,
- 0x00b090, 0xb090b0, 0x90b0b0, 0xb0b090, 0x90b090, 0xb09090, 0x9090b0,
- 0x50d090, 0xd09050, 0x9050d0, 0x5090d0, 0xd05090, 0x90d050, 0x507090,
- 0x709050, 0x905070, 0x509070, 0x705090, 0x907050, 0x503090, 0x309050,
- 0x905030, 0x509030, 0x305090, 0x903050, 0x509000, 0x905000, 0x900050,
- 0x500090, 0x009050, 0x005090, 0x509050, 0x905050, 0x505090, 0x905090,
- 0x509090, 0x909050, 0xd07090, 0x7090d0, 0x90d070, 0xd09070, 0x70d090,
- 0x9070d0, 0xd03090, 0x3090d0, 0x90d030, 0xd09030, 0x30d090, 0x9030d0,
- 0xd09000, 0x90d000, 0x9000d0, 0xd00090, 0x0090d0, 0x00d090, 0xd090d0,
- 0x90d0d0, 0xd0d090, 0x90d090, 0xd09090, 0x9090d0, 0x703090, 0x309070,
- 0x907030, 0x709030, 0x307090, 0x903070, 0x709000, 0x907000, 0x900070,
- 0x700090, 0x009070, 0x007090, 0x709070, 0x907070, 0x707090, 0x907090,
- 0x709090, 0x909070, 0x309000, 0x903000, 0x900030, 0x300090, 0x009030,
- 0x003090, 0x309030, 0x903030, 0x303090, 0x903090, 0x309090, 0x909030,
- 0x909090, 0x900000, 0x009000, 0x000090, 0x909000, 0x900090, 0x009090,
- 0xff8010
-};
-
-static unsigned char const pickMapComponent[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
- 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50,
- 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
- 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70,
- 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
- 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
- 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
- 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
- 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
- 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
- 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0,
- 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0,
- 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0,
- 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-static unsigned char const pickMapComponent444[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x00, 0x00, 0x60, 0x60, 0x60,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
- 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
- 0x00, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
- 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0,
- 0x00, 0x00, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
- 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0,
- 0xb0, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
- 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
- 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0xe0,
- 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0,
- 0xe0, 0xe0, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
- 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-#define MAX_PICK_COLORS 4096
-
-// Get the value at "index" to use for color picking. Returns a zero
-// QRgb when the table has been exhausted.
-QRgb qt_qgl_pick_color(int index)
-{
- if (index >= 0 && index < MAX_PICK_COLORS)
- return QRgb(pickColors[index] | 0xff000000);
- else
- return 0;
-}
-
-// Normalize a color that was picked out of a screen color buffer
-// so that it is a better match for something that was generated
-// by qt_qgl_pick_color(). Rounding discrepancies in the
-// low bits due to floating-point conversions are factored out.
-QRgb qt_qgl_normalize_pick_color(QRgb color, bool is444)
-{
- int red, green, blue;
- if (!is444) {
- // RGB565, RGB555, and RGB888 screens (alpha is ignored).
- red = pickMapComponent[qRed(color)];
- green = pickMapComponent[qGreen(color)];
- blue = pickMapComponent[qBlue(color)];
- } else {
- // RGB444 screens need a little more care when normalizing.
- red = pickMapComponent444[qRed(color)];
- green = pickMapComponent444[qGreen(color)];
- blue = pickMapComponent444[qBlue(color)];
- }
- return qRgb(red, green, blue);
-}
-
-QT_END_NAMESPACE
-
-#else // QGL_GENERATOR_PROGRAM
-
-#include <stdio.h>
-
-static unsigned char singlePatterns[] = {
- 1, 1, 1,
-
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1,
- 1, 1, 0,
- 1, 0, 1,
- 0, 1, 1
-};
-#define NUM_SINGLE_PATTERNS 7
-
-static unsigned char doublePatterns[] = {
- 1, 2, 0,
- 2, 1, 0,
- 2, 0, 1,
- 1, 0, 2,
- 0, 2, 1,
- 0, 1, 2,
-
- 1, 2, 1,
- 2, 1, 1,
- 1, 1, 2,
- 2, 1, 2,
- 1, 2, 2,
- 2, 2, 1
-};
-#define NUM_DOUBLE_PATTERNS 12
-
-static unsigned char triplePatterns[] = {
- 1, 2, 3,
- 2, 3, 1,
- 3, 1, 2,
- 1, 3, 2,
- 2, 1, 3,
- 3, 2, 1
-};
-#define NUM_TRIPLE_PATTERNS 6
-
-static unsigned char values[] = {
- 0x00,
- 0xff, 0x80, 0xc0, 0x40, 0xe0, 0x60, 0xa0, 0x20,
- 0xf0, 0xb0, 0x50, 0xd0, 0x70, 0x30, 0x90, 0x10
-};
-#define NUM_VALUES 16
-#define NUM_VALUES_444 10
-
-#define MAX_GENERATE 4096
-
-static unsigned char used[17][17][17];
-static int generated = 0;
-
-static void genPattern(int red, int green, int blue)
-{
- ++red;
- ++green;
- ++blue;
- if (used[red][green][blue] || generated >= MAX_GENERATE)
- return;
- used[red][green][blue] = 1;
- if ((generated % 7) == 0)
- printf("\n ");
- printf("0x%02x%02x%02x", values[red], values[green], values[blue]);
- ++generated;
- if (generated < MAX_GENERATE && (generated % 7) != 0)
- printf(", ");
- else if (generated < MAX_GENERATE)
- printf(",");
-}
-
-static void genSinglePatterns(int value)
-{
- int index, red, green, blue;
- for (index = 0; index < NUM_SINGLE_PATTERNS; ++index) {
- if (singlePatterns[index * 3] == 0)
- red = -1;
- else
- red = value;
- if (singlePatterns[index * 3 + 1] == 0)
- green = -1;
- else
- green = value;
- if (singlePatterns[index * 3 + 2] == 0)
- blue = -1;
- else
- blue = value;
- genPattern(red, green, blue);
- }
-}
-
-static void genDoublePatterns(int value1, int value2)
-{
- int index, red, green, blue;
- for (index = 0; index < NUM_DOUBLE_PATTERNS; ++index) {
- if (doublePatterns[index * 3] == 0)
- red = -1;
- else if (doublePatterns[index * 3] == 1)
- red = value1;
- else
- red = value2;
- if (doublePatterns[index * 3 + 1] == 0)
- green = -1;
- else if (doublePatterns[index * 3 + 1] == 1)
- green = value1;
- else
- green = value2;
- if (doublePatterns[index * 3 + 2] == 0)
- blue = -1;
- else if (doublePatterns[index * 3 + 2] == 1)
- blue = value1;
- else
- blue = value2;
- genPattern(red, green, blue);
- }
-}
-
-static void genTriplePatterns(int value1, int value2, int value3)
-{
- int index, red, green, blue;
- for (index = 0; index < NUM_TRIPLE_PATTERNS; ++index) {
- if (triplePatterns[index * 3] == 0)
- red = -1;
- else if (triplePatterns[index * 3] == 1)
- red = value1;
- else if (triplePatterns[index * 3] == 2)
- red = value2;
- else
- red = value3;
- if (triplePatterns[index * 3 + 1] == 0)
- green = -1;
- else if (triplePatterns[index * 3 + 1] == 1)
- green = value1;
- else if (triplePatterns[index * 3 + 1] == 2)
- green = value2;
- else
- green = value3;
- if (triplePatterns[index * 3 + 2] == 0)
- blue = -1;
- else if (triplePatterns[index * 3 + 2] == 1)
- blue = value1;
- else if (triplePatterns[index * 3 + 2] == 2)
- blue = value2;
- else
- blue = value3;
- genPattern(red, green, blue);
- }
-}
-
-static void genPatternRange(int limit)
-{
- // This will generate 4912 unique color values which are
- // reasonably well-spaced in the RGB color cube.
- int first, second, third;
- for (first = 0; first < limit; ++first) {
- genSinglePatterns(first);
- for (second = first + 1; second < limit; ++second) {
- genDoublePatterns(first, second);
- for (third = second + 1; third < limit; ++third) {
- genTriplePatterns(first, second, third);
- }
- }
- }
-}
-
-static void generateComponentMap(void)
-{
- int map[256];
- int index, value, index2;
-
- for (index = 0; index < 256; ++index)
- map[index] = 0;
-
- for (index = 0; index < NUM_VALUES; ++index) {
- value = values[index + 1];
- for (index2 = value - 8; index2 < (value + 8); ++index2) {
- if (index2 >= 0 && index2 < 256)
- map[index2] = value;
- }
- }
-
- for (index = 0; index < 256; ++index) {
- if ((index % 8) == 0)
- printf(" ");
- printf("0x%02x", map[index]);
- if (index < 255)
- printf(",");
- if ((index % 8) == 7)
- printf("\n");
- else if (index < 255)
- printf(" ");
- }
-
- // Validate the reversibility of RGB565 and RGB555 mappings.
- for (index = 0; index < 17; ++index) {
- // Integer truncation test - 5-bit for red and blue (and green RGB555).
- value = values[index] * 31 / 255;
- index2 = value * 255 / 31;
- if (values[index] != map[index2]) {
- qWarning("RGB565 (i5) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Integer truncation test - 6-bit for green.
- value = values[index] * 63 / 255;
- index2 = value * 255 / 63;
- if (values[index] != map[index2]) {
- qWarning("RGB565 (i6) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Floating point rounding test - 5-bit for red and blue.
- value = (int)((values[index] * 31.0 / 255.0) + 0.5);
- index2 = (int)((value * 255.0 / 31.0) + 0.5);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (f5) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Floating point rounding test - 6-bit for green.
- value = (int)((values[index] * 63.0 / 255.0) + 0.5);
- index2 = (int)((value * 255.0 / 63.0) + 0.5);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (f6) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Test 5-bit to 8-bit conversion using doubling (ABCDE -> ABCDEABC).
- value = values[index] * 31 / 255;
- index2 = (value << 3) | (value >> 2);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (di5) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
- value = (int)((values[index] * 31.0 / 255.0) + 0.5);
- index2 = (value << 3) | (value >> 2);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (df5) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Test 6-bit to 8-bit conversion using doubling (ABCDEF -> ABCDEFAB).
- value = values[index] * 63 / 255;
- index2 = (value << 2) | (value >> 4);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (di6) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
- value = (int)((values[index] * 63.0 / 255.0) + 0.5);
- index2 = (value << 2) | (value >> 4);
- if (values[index] != map[index2]) {
- qWarning("RGB565 (df6) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
- }
-}
-
-static void generateComponentMap444(void)
-{
- int map[256];
- int index, value, index2;
-
- for (index = 0; index < 256; ++index)
- map[index] = 0;
-
- // Populate mappings for integer conversion with truncation.
- for (index = 0; index < NUM_VALUES_444; ++index) {
- value = values[index + 1] * 15 / 255;
- value = value * 255 / 15;
- if (value > 255)
- value = 255;
- else if (value < 0)
- value = 0;
- for (index2 = value - 8; index2 < (value + 7); ++index2) {
- if (index2 >= 0 && index2 < 256)
- map[index2] = values[index + 1];
- }
- }
-
- // Add some extra mappings for floating-point conversion with rounding.
- for (index = 0; index < NUM_VALUES_444; ++index) {
- value = (int)((values[index + 1] * 15.0 / 255.0) + 0.5);
- value = (int)((value * 255.0 / 15.0) + 0.5);
- if (value > 255)
- value = 255;
- else if (value < 0)
- value = 0;
- for (index2 = value - 8; index2 < (value + 7); ++index2) {
- if (index2 >= 0 && index2 < 256 && map[index2] == 0)
- map[index2] = values[index + 1];
- }
- }
-
- for (index = 0; index < 256; ++index) {
- if ((index % 8) == 0)
- printf(" ");
- printf("0x%02x", map[index]);
- if (index < 255)
- printf(",");
- if ((index % 8) == 7)
- printf("\n");
- else if (index < 255)
- printf(" ");
- }
-
- // Validate the reversibility of RGB444 mappings.
- for (index = 0; index <= NUM_VALUES_444; ++index) {
- // Integer truncation test.
- value = values[index] * 15 / 255;
- index2 = value * 255 / 15;
- if (values[index] != map[index2]) {
- qWarning("RGB444 (i) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Floating point rounding test.
- value = (int)((values[index] * 15.0 / 255.0) + 0.5);
- index2 = (int)((value * 255.0 / 15.0) + 0.5);
- if (values[index] != map[index2]) {
- qWarning("RGB444 (f) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
-
- // Test 4-bit to 8-bit conversion using doubling (ABCD -> ABCDABCD).
- value = values[index] * 15 / 255;
- index2 = value | (value << 4);
- if (values[index] != map[index2]) {
- qWarning("RGB444 (di) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
- value = (int)((values[index] * 15.0 / 255.0) + 0.5);
- index2 = value | (value << 4);
- if (values[index] != map[index2]) {
- qWarning("RGB444 (df) failure: 0x%02X -> 0x%02X -> 0x%02X\n",
- values[index], index2, map[index2]);
- }
- }
-}
-
-int main(int argc, char *argv[])
-{
- int limit;
-
- // Run the generator multiple times using more and more of
- // the elements in the "values" table, and limit to a maximum
- // of 1024 colors.
- //
- // This will sort the output so that colors that involve elements
- // early in the table will be generated first. All combinations
- // of early elements are exhausted before moving onto later values.
- //
- // The result of this sorting should be to maximize the spacing
- // between colors that appear early in the generated output.
- // This should produce better results for color picking on
- // low-end devices with RGB565, RGB555, and RGB444 displays.
- printf("static int const pickColors[%d] = {", MAX_GENERATE);
- for (limit = 1; limit <= NUM_VALUES; ++limit)
- genPatternRange(limit);
- printf("\n};\n\n");
-
- // Generate a component mapping table for mapping 8-bit RGB
- // components to the nearest normalized value.
- printf("static unsigned char const pickMapComponent[256] = {\n");
- generateComponentMap();
- printf("};\n\n");
-
- // Generate a separate mapping table for RGB444, which needs a
- // little more care to deal with truncation errors.
- printf("static unsigned char const pickMapComponent444[256] = {\n");
- generateComponentMap444();
- printf("};\n\n");
-
- printf("#define MAX_PICK_COLORS %d\n\n", MAX_GENERATE);
-
- return 0;
-}
-
-#endif // QGL_GENERATOR_PROGRAM
diff --git a/src/threed/painting/qglpickcolors_p.h b/src/threed/painting/qglpickcolors_p.h
deleted file mode 100644
index 0249fb14..00000000
--- a/src/threed/painting/qglpickcolors_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPICKCOLORS_P_H
-#define QGLPICKCOLORS_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.
-//
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qrgb.h>
-
-QT_BEGIN_NAMESPACE
-
-QRgb qt_qgl_pick_color(int index);
-QRgb qt_qgl_normalize_pick_color(QRgb color, bool is444 = false);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/painting/qmatrix4x4stack.cpp b/src/threed/painting/qmatrix4x4stack.cpp
deleted file mode 100644
index c723cd4d..00000000
--- a/src/threed/painting/qmatrix4x4stack.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qmatrix4x4stack.h"
-#include "qmatrix4x4stack_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QMatrix4x4Stack
- \brief The QMatrix4x4Stack class manages stacks of transformation matrices in GL applications.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-
- Transformation matrices are one of the basic building blocks of
- 3D applications, allowing object models to be positioned, scaled,
- rotated, and projected onto the screen.
-
- GL systems support several standard kinds of matrices, particularly
- modelview and projection matrices. These matrices are typically
- organized into stacks, which allow the current matrix state to be
- saved with push() and restored later with pop().
-
- QMatrix4x4Stack assists QGLPainter with the management of matrix
- stacks, providing operations to set and modify transformation
- matrices in each of the standard matrix stacks.
-
- In the following example, a standard orthographic projection matrix for a
- view is set via the QGLPainter::projectionMatrix() stack, and
- then a modelview matrix is set via the QGLPainter::modelViewMatrix()
- stack to scale and translate an object prior to drawing:
-
- \code
- QGLPainter painter(this);
-
- QMatrix4x4 projm;
- projm.ortho(window->rect());
- painter.projectionMatrix() = projm;
-
- painter.modelViewMatrix().setToIdentity();
- painter.modelViewMatrix().translate(-1.0f, 2.0f, 0.0f);
- painter.modelViewMatrix().scale(0.5f);
- \endcode
-
- Later, the application can save the current modelview matrix state
- and draw a different object with a different modelview matrix:
-
- \code
- painter.modelViewMatrix().push();
- painter.modelViewMatrix().setToIdentity();
- painter.modelViewMatrix().scale(2.0f);
- \endcode
-
- For efficiency, the matrix values are kept client-side until they
- are needed by a QGLPainter::draw() operation. Until then, changes
- to the matrix will not be reflected in the GL server. The application
- can force the GL server to update the server with a call to
- QGLPainter::update().
-
- QMatrix4x4Stack is supported on all GL platforms, including OpenGL/ES 2.0
- which doesn't support matrix stacks natively. On that platform, the
- matrix stack is simulated in client memory. When the application
- selects a shader program to draw under OpenGL/ES 2.0, it calls
- top() to obtain the actual value to be set on the shader program.
-
- \sa QGLPainter
-*/
-
-/*!
- Creates a matrix stack.
-*/
-QMatrix4x4Stack::QMatrix4x4Stack()
- : d_ptr(new QMatrix4x4StackPrivate)
-{
-}
-
-/*!
- Destroy this matrix stack.
-*/
-QMatrix4x4Stack::~QMatrix4x4Stack()
-{
-}
-
-/*!
- Pushes the current matrix onto the matrix stack. The matrix can
- be restored with pop(). The new top of stack will have the
- same value as the previous top of stack.
-
- The depths of the traditional \c{GL_MODELVIEW} and \c{GL_PROJECTION}
- matrix stacks in the GL server are system-dependent and easy to
- overflow in nested rendering code using \c{glPushMatrix()}.
- By contrast, the push() function provides an arbitrary-sized stack
- in client memory.
-
- \sa pop(), top()
-*/
-void QMatrix4x4Stack::push()
-{
- Q_D(QMatrix4x4Stack);
- d->stack.push(d->matrix);
-}
-
-/*!
- Pops the top-most matrix from this matrix stack and sets the
- current matrix to the next value down. Does nothing if the
- matrix stack contains a single entry.
-
- \sa push()
-*/
-void QMatrix4x4Stack::pop()
-{
- Q_D(QMatrix4x4Stack);
- if (!d->stack.isEmpty())
- d->matrix = d->stack.pop();
- d->isDirty = true;
-}
-
-/*!
- Set the matrix at the top of this matrix stack to the identity matrix.
-
- \sa operator=()
-*/
-void QMatrix4x4Stack::setToIdentity()
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.setToIdentity();
- d->isDirty = true;
-}
-
-/*!
- Returns a const reference to the current matrix at the top of this
- matrix stack. This is typically used to fetch the matrix so it can
- be set on user-defined shader programs.
-
- \sa operator=()
-*/
-const QMatrix4x4 &QMatrix4x4Stack::top() const
-{
- Q_D(const QMatrix4x4Stack);
- return d->matrix;
-}
-
-/*!
- \fn QMatrix4x4Stack::operator const QMatrix4x4 &() const
-
- Returns a const reference to the current matrix at the top of
- this matrix stack.
-
- \sa top()
-*/
-
-/*!
- Assigns \a matrix to the matrix at the top of this matrix stack.
-
- \sa top()
-*/
-QMatrix4x4Stack& QMatrix4x4Stack::operator=(const QMatrix4x4& matrix)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix = matrix;
- d->isDirty = true;
- return *this;
-}
-
-/*!
- Multiplies the matrix at the top of this matrix stack by \a matrix.
-
- \sa top()
-*/
-QMatrix4x4Stack& QMatrix4x4Stack::operator*=(const QMatrix4x4& matrix)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix *= matrix;
- d->isDirty = true;
- return *this;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that translates coordinates by (\a x, \a y, \a z). The following example
- translates the modelview matrix by (1, -3, 0):
-
- \code
- QGLPainter painter(this);
- painter.modelViewMatrix().translate(1.0f, -3.0f, 0.0f);
- \endcode
-
- \sa scale(), rotate()
-*/
-void QMatrix4x4Stack::translate(qreal x, qreal y, qreal z)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.translate(x, y, z);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix statck by another
- that translates coordinates by the components of \a vector.
-
- \sa scale(), rotate()
-*/
-void QMatrix4x4Stack::translate(const QVector3D& vector)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.translate(vector);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that scales coordinates by the components \a x, \a y, and \a z.
- The following example scales the modelview matrix by (1, 2, 1):
-
- \code
- QGLPainter painter(this);
- painter.modelViewMatrix().scale(1.0f, 2.0f, 1.0f);
- \endcode
-
- \sa translate(), rotate()
-*/
-void QMatrix4x4Stack::scale(qreal x, qreal y, qreal z)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.scale(x, y, z);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that scales coordinates by the given \a factor. The following example
- scales the modelview matrix by a factor of 2:
-
- \code
- QGLPainter painter(this);
- painter.modelViewMatrix().scale(2.0f);
- \endcode
-
- \sa translate(), rotate()
-*/
-void QMatrix4x4Stack::scale(qreal factor)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.scale(factor);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that scales coordinates by the components of \a vector.
-
- \sa translate(), rotate()
-*/
-void QMatrix4x4Stack::scale(const QVector3D& vector)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.scale(vector);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that rotates coordinates through \a angle degrees about the vector
- (\a x, \a y, \a z). The following example rotates the modelview
- matrix by 45 degress about the vector (1, -3, 0):
-
- \code
- QGLPainter painter(this);
- painter.modelViewMatrix().rotate(45.0f, 1.0f, -3.0f, 0.0f);
- \endcode
-
- \sa scale(), translate()
-*/
-void QMatrix4x4Stack::rotate(qreal angle, qreal x, qreal y, qreal z)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.rotate(angle, x, y, z);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by another
- that rotates coordinates through \a angle degrees about \a vector.
-
- \sa scale(), translate()
-*/
-void QMatrix4x4Stack::rotate(qreal angle, const QVector3D& vector)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.rotate(angle, vector);
- d->isDirty = true;
-}
-
-/*!
- Multiplies the current matrix at the top of this matrix stack by the
- \a quaternion. Thus \c {painter->modelViewMatrix().rotate(quaternion)}
- is equivalent to the following code:
- \code
- QMatrix4x4 mat;
- mat.rotate(quaternion);
- painter->modelViewMatrix() *= mat;
- \endcode
- which rotates coordinates according to the given \a quaternion.
-
- \sa scale(), translate()
-*/
-void QMatrix4x4Stack::rotate(const QQuaternion &quaternion)
-{
- Q_D(QMatrix4x4Stack);
- d->matrix.rotate(quaternion);
- d->isDirty = true;
-}
-
-/*!
- Returns true if the top of this matrix stack has been modified;
- false otherwise.
-
- \sa setDirty()
-*/
-bool QMatrix4x4Stack::isDirty() const
-{
- Q_D(const QMatrix4x4Stack);
- return d->isDirty;
-}
-
-/*!
- Sets the \a dirty flag on this matrix stack, which indicates
- if it has been modified.
-
- A matrix stack may also be set to dirty by translate(),
- scale(), operator*(), etc.
-
- \sa isDirty()
-*/
-void QMatrix4x4Stack::setDirty(bool dirty)
-{
- Q_D(QMatrix4x4Stack);
- d->isDirty = dirty;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/painting/qmatrix4x4stack.h b/src/threed/painting/qmatrix4x4stack.h
deleted file mode 100644
index efb8d85b..00000000
--- a/src/threed/painting/qmatrix4x4stack.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QMATRIX4X4STACK_H
-#define QMATRIX4X4STACK_H
-
-#include "qt3dglobal.h"
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QMatrix4x4StackPrivate;
-
-class Q_QT3D_EXPORT QMatrix4x4Stack
-{
-public:
- QMatrix4x4Stack();
- ~QMatrix4x4Stack();
-
- const QMatrix4x4 &top() const;
-
- void push();
- void pop();
-
- void setToIdentity();
-
- void translate(qreal x, qreal y, qreal z);
- void translate(const QVector3D& vector);
- void scale(qreal x, qreal y, qreal z);
- void scale(qreal factor);
- void scale(const QVector3D& vector);
- void rotate(qreal angle, qreal x, qreal y, qreal z);
- void rotate(qreal angle, const QVector3D& vector);
- void rotate(const QQuaternion &quaternion);
-
- QMatrix4x4Stack& operator=(const QMatrix4x4& matrix);
- QMatrix4x4Stack& operator*=(const QMatrix4x4& matrix);
-
- operator const QMatrix4x4 &() const;
-
- bool isDirty() const;
- void setDirty(bool dirty);
-
-private:
- Q_DISABLE_COPY(QMatrix4x4Stack)
- Q_DECLARE_PRIVATE(QMatrix4x4Stack)
-
- QScopedPointer<QMatrix4x4StackPrivate> d_ptr;
-
- friend class QGLPainter;
-};
-
-inline QMatrix4x4Stack::operator const QMatrix4x4 &() const
-{
- return top();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/painting/qmatrix4x4stack_p.h b/src/threed/painting/qmatrix4x4stack_p.h
deleted file mode 100644
index ac6620ef..00000000
--- a/src/threed/painting/qmatrix4x4stack_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QMATRIX4X4STACK_P_H
-#define QMATRIX4X4STACK_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.
-//
-
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qstack.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QMatrix4x4StackPrivate
-{
-public:
- QMatrix4x4StackPrivate() : isDirty(true) {}
-
- QMatrix4x4 matrix;
- QStack<QMatrix4x4> stack;
- bool isDirty;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/scene/qglabstractscene.cpp b/src/threed/scene/qglabstractscene.cpp
deleted file mode 100644
index ee685e76..00000000
--- a/src/threed/scene/qglabstractscene.cpp
+++ /dev/null
@@ -1,605 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglabstractscene.h"
-#include "qglsceneformatplugin.h"
-#include "qglpicknode.h"
-
-// copied private header
-#include "qfactoryloader_p.h"
-
-#include <QtCore/qfile.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qlibraryinfo.h>
-#include <QtNetwork/qnetworkreply.h>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qpluginloader.h>
-#include <QBuffer>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAbstractScene
- \brief The QGLAbstractScene class represents a 3D scene consisting of zero or more QGLSceneNode instances.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- Scenes are typically created by 3D modelling packages and then loaded
- into the application via a QGLSceneFormatPlugin; but they can also be
- constructed programatically. The functions in this
- class provide access to major scene objects so that they can be
- applied or drawn whenever the application decides.
-
- QGLAbstractScene presents a very simple model of a 3D scene. Subclasses
- implement the specific scene graph and object representations in a
- manner specific to the package's format. Subclasses may also provide
- functionality to create new objects at runtime, but this is not required.
-
- The scene is defined to consist of a number of important objects
- of the following types:
-
- \list
- \o Camera objects define a viewing position in world-coordinates and a
- projection that maps 3D world co-ordinates to 2D screen co-ordinates.
- Camera objects should inherit from QGLCamera.
- \o Main objects designate the major elements of the scene besides
- cameras, lights, and effects. Usually they inherit from QGLSceneNode.
- \o Light objects define positions and parameters for lighting the scene.
- Light objects should inherit from QGLLightParameters.
- \o Effect objects define materials, shaders, and textures for use in
- rendering the surface of objects. Normally effects are activated
- automatically when main objects are drawn. But effects can be used
- independently if the 3D format is acting as a library of effects.
- \o Mesh objects define geometry information independently of effects.
- Normally meshes are drawn automatically with an appropriate effect
- when main objects are drawn. But meshes can be used independently
- if the 3D format is acting as a library of meshes. Mesh objects
- should inherit from QGLSceneNode.
- \endlist
-
- Typically, the full scene represented by an external model format
- is not interesting to the application. 3D modelling packages
- regularly insert cameras, lights, effects, and other library
- objects that are useful to the modelling package, but not the
- application. The mainNode() is usually the most interesting
- to applications.
-
- QGLAbstractScene makes it easy to access the major scene elements
- with object(), objects(), and mainNode().
-
- There are many other kinds of objects in the scene that may not
- be accessible via QGLAbstractScene because they are not considered
- "important" enough. For example, a file that contains the data
- for a skateboard object would contain many objects for the board,
- wheels, texturing effects, animations, and so on. The application
- may only be interested in the skateboard as a whole, and not its
- sub-components. The skateboard would be considered an important
- main object in this case, which can be easily accessed and
- incorporated into the application's logic.
-
- Each Subclass needs to provide its own policy for deciding which
- objects are considered "important".
-
- \sa QGLSceneNode, QGLSceneFormatPlugin
-*/
-
-class QGLAbstractScenePrivate
-{
-public:
- QGLAbstractScenePrivate()
- : picking(false), nextPickId(-1), pickNodesDirty(true) {}
- bool picking;
- int nextPickId;
- QList<QGLPickNode*> pickNodes;
- QSet<QGLSceneNode*> pickable;
- bool pickNodesDirty;
-};
-
-/*!
- Constructs a 3D scene and attaches it to \a parent.
-*/
-QGLAbstractScene::QGLAbstractScene(QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLAbstractScenePrivate)
-{
-}
-
-/*!
- Destroys this 3D scene.
-*/
-QGLAbstractScene::~QGLAbstractScene()
-{
-}
-
-/*!
- \internal
-*/
-void QGLAbstractScene::childEvent(QChildEvent *event)
-{
- Q_D(QGLAbstractScene);
- if (event->type() == QEvent::ChildAdded)
- d->pickNodesDirty = true;
-}
-
-/*!
- Sets this scene to be pickable if \a enable is true, otherwise picking
- is disabled. If the scene is set to be pickable, pick nodes are
- generated by calling generatePickNodes().
-
- \sa generatePickNodes(), pickable()
-*/
-void QGLAbstractScene::setPickable(bool enable)
-{
- Q_D(QGLAbstractScene);
- if (enable != d->picking)
- {
- d->picking = enable;
- if (d->picking)
- generatePickNodes();
- }
-}
-
-/*!
- Returns true if this scene is pickable.
-
- \sa setPickable()
-*/
-bool QGLAbstractScene::pickable() const
-{
- Q_D(const QGLAbstractScene);
- return d->picking;
-}
-
-/*!
- Generates QGLPickNode instances for important QGLSceneNode instances that are
- pickable. Objects that are either not important or not pickable can
- be omitted. The default implementation simply generates pick nodes
- for every top level object of type QGLSceneNode.
-
- Sub-classes may implement different schemes for picking. When doing
- so parent the QGLPickNode objects onto the scene, so that they will
- appear in the list returned by pickNodes()
-
- \sa pickNodes(), setPickable()
-*/
-void QGLAbstractScene::generatePickNodes()
-{
- Q_D(QGLAbstractScene);
- QList<QObject *> objs = objects();
- QList<QObject *>::iterator it = objs.begin();
- d->pickNodes.clear();
- for ( ; it != objs.end(); ++it)
- {
- QGLSceneNode *n = qobject_cast<QGLSceneNode *>(*it);
- if (d) {
- if (!d->pickable.contains(n)) {
- n->setPickNode(new QGLPickNode(this));
- d->pickable.insert(n);
- }
- d->pickNodes.append(n->pickNode());
- }
- }
-}
-
-/*!
- Increments and returns the next available pick id for this scene.
-*/
-int QGLAbstractScene::nextPickId()
-{
- return ++d_ptr->nextPickId;
-}
-
-/*!
- Returns a list of the pick nodes that have been parented onto this
- scene.
-
- \sa generatePickNodes()
-*/
-QList<QGLPickNode *> QGLAbstractScene::pickNodes() const
-{
- if (d_ptr->pickNodesDirty)
- {
- const_cast<QGLAbstractScene*>(this)->generatePickNodes();
- d_ptr->pickNodesDirty = false;
- }
- return d_ptr->pickNodes;
-}
-
-/*!
- \fn QList<QObject *> QGLAbstractScene::objects() const
-
- Returns a list of all objects in the scene which are considered
- important.
-
- Important objects will typically be the main mesh object, cameras,
- lights, and other top-level objects. Sub-meshes and effects
- are normally not considered important unless the scene is
- acting as a library of meshes and effects.
-
- \sa objectNames(), object(), mainNode()
-*/
-
-/*!
- Returns a list of the names of all objects in the scene which
- are considered important, and which have non-empty names
- associated with them.
-
- The default implementation calls objects() and then compiles a list
- of all non-empty object names.
-
- \sa objects()
-*/
-QStringList QGLAbstractScene::objectNames() const
-{
- QList<QObject *> objs = objects();
- QStringList names;
- for (int index = 0; index < objs.count(); ++index) {
- QObject *object = objs.at(index);
- if (object) {
- QString name = object->objectName();
- if (!name.isEmpty())
- names += name;
- }
- }
- return names;
-}
-
-/*!
- Returns the scene object that has the specified \a name;
- or null if the object was not found.
-
- The default implementation searches objects() for an object that
- matches \a name.
-
- \sa objects()
-*/
-QObject *QGLAbstractScene::object(const QString& name) const
-{
- if (name.isEmpty())
- return 0;
- QList<QObject *> objs = objects();
- for (int index = 0; index < objs.count(); ++index) {
- QObject *object = objs.at(index);
- if (object && object->objectName() == name)
- return object;
- }
- return 0;
-}
-
-
-/*!
- \fn QGLSceneNode *QGLAbstractScene::mainNode() const
-
- Returns the main mesh node in the scene, or null if the scene
- does not contain a main mesh node.
-
- \sa objects()
-*/
-
-#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGLSceneFormatFactoryInterface_iid, 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
- string, then the format will be autodetected from the filename
- extension of \a device. The \a url specifies the location of
- the data in \a device so that relative resources can be located.
-
- The \a options string is passed to the underlying format loader
- and its meaning and format depend on the loader. For example the
- format string for the .3ds loader accepts the following options:
- \list
- \o ForceSmooth - average normals for a smooth appearance
- \o ForceFaceted - per face normals for a faceted appearance
- \o NativeIndices - map native indices for poorly smoothed models
- \o CorrectNormals - fix inverted normals on models with bad windings
- \o CorrectAcute - fix normals on models that smooth acute angles
- \endlist
-
- The options may be specified globally for the whole model, or just
- for a particular mesh.
-
- In this example smoothing is forced on globally, and native indices
- are used on just the mesh called "BattCoverMesh".
-
- \code
- QString op = "ForceSmooth BattCoverMesh=NativeIndices";
- QString file = "music-player.3ds";
- QGLAbstractScene *scene = QGLAbstractScene::loadScene(file, QString(), op);
- \endcode
-
- Returns the scene object, or null if the scene could not be loaded
- or the \a format was not supported by any of the plugins.
-
- \sa QGLSceneFormatPlugin
-*/
-QGLAbstractScene *QGLAbstractScene::loadScene
- (QIODevice *device, const QUrl& url, const QString& format, const QString &options)
-{
-#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
-
- QFactoryLoader *l = loader();
- QStringList keys = l->keys();
-
- // If the format is not specified, then use the filename/url extension.
- QString fmt = format;
- if (fmt.isEmpty()) {
- //First try to resolve a file io device
- QFile *file = qobject_cast<QFile *>(device);
- QString name;
- if (file) {
- name = file->fileName();
- } else {
- //Next try to resolve a network io device
- QNetworkReply *reply = qobject_cast<QNetworkReply *>(device);
- if (reply)
- name = reply->url().path();
- else {
- //otherwise just use the url pathname.
- name = url.path();
- }
- }
- int dot = name.lastIndexOf(QLatin1Char('.'));
- QString suffix = name.mid(dot+1).toLower();
- int index = keys.indexOf(suffix);
- if (index >= 0)
- fmt = suffix;
- }
-
- // 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;
- }
- }
-
- // 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);
- Q_UNUSED(format);
- return 0;
-#endif // QT_NO_LIBRARY || QT_NO_SETTINGS
-}
-
-/*!
- Loads a scene from the internet in the specified \a format using
- the registered scene format plugins. If \a format is an empty
- string, then the format will be autodetected from the filename
- extension of the \a url, which specifies the location of
- the data online.
-
- The \a options string is passed to the underlying format loader
- and its meaning and format depend on the loader. For example the
- format string for the .3ds loader accepts the following options:
- \list
- \o ForceSmooth - average normals for a smooth appearance
- \o ForceFaceted - per face normals for a faceted appearance
- \o NativeIndices - map native indices for poorly smoothed models
- \o CorrectNormals - fix inverted normals on models with bad windings
- \o CorrectAcute - fix normals on models that smooth acute angles
- \endlist
-
- The options may be specified globally for the whole model, or just
- for a particular mesh.
-
- In this example smoothing is forced on globally, and native indices
- are used on just the mesh called "BattCoverMesh".
-
- \code
- QString op = "ForceSmooth BattCoverMesh=NativeIndices";
- QString url = "http://www.example.url.com/music-player.3ds";
- QGLAbstractScene *scene = QGLAbstractScene::loadScene(url, QString(), op);
- \endcode
-
- Returns the scene object, or null if the scene could not be loaded
- or the \a format was not supported by any of the plugins.
-
- The scene object returned by this will contain only a single stub
- node at the root of the scenegraph, which will be filled out later
- once the asynchronous download of the scene data is complete.
-
- \sa QGLSceneFormatPlugin
-*/
-QGLAbstractScene *QGLAbstractScene::loadScene
- (const QUrl& url, const QString& format, const QString &options)
-{
- return QGLAbstractScene::loadScene(0, url, format, options);
-}
-
-/*!
- Loads a scene from \a fileName in the specified \a format, with the
- supplied \a options, and using the registered scene format plugins.
-
- If \a format is an empty string, then the format will be autodetected
- from the extension of \a fileName.
-
- The \a options string is passed to the underlying format loader
- and its meaning and format depend on the loader. See the doc above
- for loadScene() for details on the 3ds format options.
-
- Returns the scene object, or null if the scene could not be loaded
- or the \a format was not supported by any of the plugins.
-
- \sa QGLSceneFormatPlugin
-*/
-QGLAbstractScene *QGLAbstractScene::loadScene
- (const QString& fileName, const QString& format, const QString &options)
-{
- QUrl fileUrl(fileName);
-
- if (fileUrl.scheme()!="http" && fileUrl.scheme()!="ftp") {
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly))
- {
- if (options.contains(QLatin1String("ShowWarnings")))
- qWarning("Could not read %s", qPrintable(fileName));
- return 0;
- }
- QFileInfo fi(fileName);
- QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
- return loadScene(&file, url, format, options);
- } else {
- //the following call should initiate network loading on the correct
- //downloader class.
- return loadScene(QUrl(fileName), format, options);
- }
-}
-
-/*!
- \enum QGLAbstractScene::FormatListType
- This enum specifies the format of the list returned by the supportedFormats() function.
-
- \value AsFilter Return a format list that may be used as a filter.
- \value AsSuffix Return a format list that is simply the filename suffixes.
-*/
-
-/*!
- Returns a list of all supported formats known by currently available
- sceneformat plugins, in the format type \a t.
-
- If \a t is QGLAbstractScene::AsFilter then the result may be passed
- to QDir::setNameFilters(), or used in other filters. This is the default.
-
- For example to create a file dialog to load model files use this:
- \code
- QString modelsDir = QDir::toNativeSeperators(QDir::homePath());
- QString filter = tr("Models (%1)").arg(QAbstractScene::supportedFormats().join(" "));
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open File"), modelsDir, filter));
- \endcode
-
- 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)
-{
- QStringList formats;
- QSet<QString> formatSet;
- QSet<QString> dirSet;
- QStringList pluginPaths = QCoreApplication::libraryPaths();
- QStringList::const_iterator it = pluginPaths.constBegin();
- for ( ; it != pluginPaths.constEnd(); ++it)
- {
- QString path = *it;
- QDir sceneformatDir(path + QLatin1String("/sceneformats"));
- path = sceneformatDir.absolutePath();
- if (!sceneformatDir.exists() || dirSet.contains(path))
- continue;
- dirSet.insert(path);
- sceneformatDir.setFilter(QDir::Files);
- QStringList entries = sceneformatDir.entryList();
- QStringList::const_iterator fit = entries.constBegin();
- for ( ; fit != entries.constEnd(); ++fit)
- {
- QString fi = *fit;
- QPluginLoader loader(sceneformatDir.absoluteFilePath(fi));
- QObject *inst = loader.instance();
- QGLSceneFormatFactoryInterface *iface = qobject_cast<QGLSceneFormatFactoryInterface*>(inst);
- if (iface)
- {
- QStringList formatKeys = iface->keys();
- QStringList::const_iterator kit = formatKeys.constBegin();
- for ( ; kit != formatKeys.constEnd(); ++kit)
- {
- QString k = *kit;
- if (!formatSet.contains(k) && !k.contains("/")) // dont add mime-type keys
- {
- if (t == AsFilter)
- k.prepend("*.");
- formatSet.insert(k);
- formats.append(k);
- }
- }
- }
- }
- }
- return formats;
-}
-
-/*!
- \fn QGLAbstractScene::sceneUpdated()
- \internal
- This signal should be emitted when a network download of a scene has
- been completed.
-
- The user is left to implement the exact mechanism behind the scenes which
- causes this signal to be emitted, and is responsible for the handling
- of the signal.
-*/
-
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglabstractscene.h b/src/threed/scene/qglabstractscene.h
deleted file mode 100644
index 8fc7a5fa..00000000
--- a/src/threed/scene/qglabstractscene.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLABSTRACTSCENE_H
-#define QGLABSTRACTSCENE_H
-
-#include "qt3dglobal.h"
-#include "qglscenenode.h"
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLAbstractScenePrivate;
-class QIODevice;
-class QGLPickNode;
-
-class Q_QT3D_EXPORT QGLAbstractScene : public QObject
-{
- Q_OBJECT
-public:
- explicit QGLAbstractScene(QObject *parent = 0);
- virtual ~QGLAbstractScene();
-
- virtual void setPickable(bool enable);
- virtual bool pickable() const;
- virtual void generatePickNodes();
- QList<QGLPickNode *> pickNodes() const;
- int nextPickId();
-
- virtual QList<QObject *> objects() const = 0;
- virtual QStringList objectNames() const;
- virtual QObject *object(const QString& name) const;
- virtual QGLSceneNode *mainNode() const = 0;
-
- static QGLAbstractScene *loadScene
- (const QUrl& url, const QString& format = QString(),
- const QString& options = QString());
- static QGLAbstractScene *loadScene
- (QIODevice *device, const QUrl& url, const QString& format = QString(),
- const QString& options = QString());
- static QGLAbstractScene *loadScene
- (const QString& fileName, const QString& format = QString(),
- const QString& options = QString());
-
- enum FormatListType {
- AsFilter, AsSuffix
- };
-
- static QStringList supportedFormats(FormatListType t = AsFilter);
-
-signals:
- void sceneUpdated();
-
-protected:
- void childEvent(QChildEvent * event);
-
-private:
- QScopedPointer<QGLAbstractScenePrivate> d_ptr;
-
- Q_DISABLE_COPY(QGLAbstractScene)
- Q_DECLARE_PRIVATE(QGLAbstractScene)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/scene/qglpicknode.cpp b/src/threed/scene/qglpicknode.cpp
deleted file mode 100644
index 8275aacd..00000000
--- a/src/threed/scene/qglpicknode.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglpicknode.h"
-#include "qglabstractscene.h"
-
-#include <QtGui/qevent.h>
-
-/*!
- \class QGLPickNode
- \brief The QGLPickNode class enables picking for objects in a 3D scene.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- QGLPickNode is a QObject sub-class, relatively light-weight, that can
- shadow QSceneObject instances and provide picking capability. The
- QGLPickNode instance receives events sent to it by picking views, such
- as the QGLView class, and emits relevant signals in response.
-
- QGLSceneObjects wanting to support picking, should implement the methods
- \list
- \o QGLSceneNode::pickNode()
- \o QGLSceneNode::setPickNode()
- \endlist
- and also implement rendering such that the QGLPainter has the relevant
- \l{QGLPainter::setObjectPickId()}{pick id function} called.
-
- These functions are already implemented for the QGLSceneNode object type.
-
- Picking can then be simply enabled by calling the QGLAbstractScene function
- setPickable() to turn on picking and generate pick nodes for the relevant
- scene objects.
-
- In order to respond to picking, the view class should simply register the
- picknodes, and connect a relevant slot to the pick nodes signal.
-
- For the QGLView class that code is simply:
- \code
- QList<QGLPickNode *>nodes = manager->pickNodes();
- foreach (QGLPickNode *node, nodes)
- {
- registerObject(node->id(), node);
- connect(node, SIGNAL(clicked()),
- this, SLOT(objectPicked()));
- }
- \endcode
-
- The pick nodes should be unregistered with similar code for the QGLView if
- switching to a different scene.
-
- To be able to recover the relevant QGLSceneNode inside the called slot,
- the object may be set onto the QGLPickNode with the setTarget() function,
- and recovered with target() inside the slot, since the QGLPickNode will
- be the sender() for the slot.
-
- QGLSceneNode already sets itself as the target during the pick enable step.
-
- \sa QGLSceneNode, QGLView
-*/
-
-/*!
- Construct a new QGLPickNode object managed by and parented onto
- the \a parent scene. The nextPickId() function will be called on
- \a parent to assign a pick id to this new node.
-*/
-QGLPickNode::QGLPickNode(QGLAbstractScene *parent) :
- QObject(parent), m_id(-1), m_target(0)
-{
- if (parent)
- m_id = parent->nextPickId();
-}
-
-/*!
- \fn int QGLPickNode::id() const
- Returns the unique id for this node. This value is assigned by
- the parent scene for this node and should be different for every
- node in the scene. Returns -1 if the id has not been set yet.
-
- \sa setId()
-*/
-
-/*!
- \fn void QGLPickNode::setId(int id)
- Sets the unique \a id for this node. Generally this function should not
- be needed, since the constructor causes a unique id to be obtained
- from the parent scene. This function exists mainly for testing
- purposes.
-
- \sa id()
-*/
-
-/*!
- \fn QGLSceneNode *QGLPickNode::target() const
- Returns the QGLSceneNode which is the target of this pick node;
- null if the target has not been set yet.
-
- \sa setTarget()
-*/
-
-/*!
- \fn void QGLPickNode::setTarget(QGLSceneNode *target)
- Sets the \a target for this pick node.
-
- \sa target()
-*/
-
-/*!
- \fn void QGLPickNode::pressed()
- Signal emitted when the scene object for this node has the mouse pressed
- while the cursor is on the object in the scene.
-*/
-
-/*!
- \fn void QGLPickNode::released()
- Signal emitted when the scene object for this node has the mouse released
- while the cursor is on the object in the scene.
-*/
-
-/*!
- \fn void QGLPickNode::clicked()
- Signal emitted when the scene object for this node has the mouse pressed
- and then released while the cursor is on the object in the scene.
-*/
-
-/*!
- \fn void QGLPickNode::doubleClicked()
- Signal emitted when the scene object for this node has the mouse clicked
- twice in succession while the cursor is on the object in the scene.
-*/
-
-/*!
- \fn void QGLPickNode::hoverChanged()
- Signal emitted when the scene object for this node has the mouse moved
- into or out of this object in the scene.
-*/
-
-/*!
- \internal
-*/
-bool QGLPickNode::event(QEvent *e)
-{
- // ripped off from teaservice demo, but not before the same code
- // was ripped off and put in item3d.cpp - those should probably all
- // use this implementation here
- if (e->type() == QEvent::MouseButtonPress)
- {
- QMouseEvent *me = (QMouseEvent *)e;
- if (me->button() == Qt::LeftButton)
- emit pressed();
- }
- else if (e->type() == QEvent::MouseButtonRelease)
- {
- QMouseEvent *me = (QMouseEvent *)e;
- if (me->button() == Qt::LeftButton)
- {
- emit released();
- if (me->x() >= 0) // Positive: inside object, Negative: outside.
- emit clicked();
- }
- }
- else if (e->type() == QEvent::MouseButtonDblClick)
- {
- emit doubleClicked();
- }
- else if (e->type() == QEvent::Enter)
- {
- //m_hovering = true;
- emit hoverChanged();
- }
- else if (e->type() == QEvent::Leave)
- {
- //m_hovering = false;
- emit hoverChanged();
- }
- return QObject::event(e);
-}
diff --git a/src/threed/scene/qglpicknode.h b/src/threed/scene/qglpicknode.h
deleted file mode 100644
index 5b53d5ff..00000000
--- a/src/threed/scene/qglpicknode.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPICKNODE_H
-#define QGLPICKNODE_H
-
-#include <QtCore/qobject.h>
-#include "qt3dglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLAbstractScene;
-class QGLSceneNode;
-class QEvent;
-
-class Q_QT3D_EXPORT QGLPickNode : public QObject
-{
- Q_OBJECT
-public:
- explicit QGLPickNode(QGLAbstractScene *parent = 0);
- int id() const { return m_id; }
- void setId(int id) { m_id = id; }
-
- QGLSceneNode *target() const { return m_target; }
- void setTarget(QGLSceneNode *target) { m_target = target; }
-
-Q_SIGNALS:
- void pressed();
- void released();
- void clicked();
- void doubleClicked();
- void hoverChanged();
-
-public Q_SLOTS:
-
-protected:
- bool event(QEvent *e);
- int m_id;
- QGLSceneNode *m_target;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLPICKNODE_H
diff --git a/src/threed/scene/qglrenderorder.cpp b/src/threed/scene/qglrenderorder.cpp
deleted file mode 100644
index adaa5883..00000000
--- a/src/threed/scene/qglrenderorder.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglrenderorder.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLRenderOrder
- \brief The QGLRenderOrder class represents an order of a scene node during rendering.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- The QGLRenderOrder class works with the QGLRenderSequencer to optimize
- the rendering order of scene nodes.
-
- The class encapsulates the ordering with which QGLSceneNodes appear in the
- rendering of a scene. Every scene node that has the same rendering properties
- maps to the same QGLRenderOrder.
-
- QGLRenderOrder instances are based on a scene node, and the path through
- the scene graph by which the node was reached. This is necessary since the
- same node may appear with different rendering properties in multiple
- different places in the rendering graph.
-
- For example a node holding a model of a pawn chess piece may appear in
- several different places on a board, some with a white material and some
- with a black material.
-
- To capture this concept QGLRenderOrder instances are constructed from a
- pointer to a QGLSceneNode, and a QGLRenderState instance.
-
- A render order then calculates the effective values of its various attributes
- based on both the node, and the state.
-
- Custom render orders may be created by sub-classing QGLRenderOrderComparator
- and reimplementing the following methods:
- \list
- \i isEqualTo()
- \i isLessThan()
- \endlist
-
- By default all nodes which have the same effect type are rendered together,
- and then within that, those nodes which have the same material are
- rendered together.
-
- \sa QGLRenderOrderComparator
-*/
-
-/*!
- \fn QGLRenderOrder::QGLRenderOrder(const QGLSceneNode *node, const QGLRenderState &state)
- Creates a new QGLRenderOrder instance that encapsulates the order in this
- render pass represented by the given \a node and \a state. The \a node
- defaults to NULL, and the \a state defaults to a default constructed
- invalid QGLRenderState.
-*/
-
-/*!
- \fn QGLRenderOrder::~QGLRenderOrder()
- Destroys this QGLRenderOrder and recovers any resources.
-*/
-
-/*!
- Returns a hash value representing the effect set onto the node for
- this render order.
-*/
-uint QGLRenderOrder::effectHash() const
-{
- quint64 result = 0;
- if (effectiveHasEffect())
- {
- QGLAbstractEffect *eff = effectiveUserEffect();
- if (eff)
- result = reinterpret_cast<quint64>(eff);
- else
- result = effectiveStandardEffect() + 1;
- Q_ASSERT(result);
- }
- return qHash(result);
-}
-
-/*!
- Returns true if this QGLRenderOrder is equal to the \a rhs, otherwise
- returns false. Reimplement this function when creating a sub-class of
- QGLRenderOrder.
-
- \sa isLessThan()
-*/
-bool QGLRenderOrder::isEqual(const QGLRenderOrder &rhs) const
-{
- if (this == &rhs)
- return true;
- bool result = false;
- bool thisHasEffect = effectiveHasEffect();
- bool thatHasEffect = rhs.effectiveHasEffect();
- if (thisHasEffect && thatHasEffect)
- {
- QGLAbstractEffect *eff = effectiveUserEffect();
- if (eff)
- result = (eff == rhs.effectiveUserEffect());
- else
- result = (effectiveStandardEffect() == rhs.effectiveStandardEffect());
- }
- else
- {
- result = (thisHasEffect == thatHasEffect);
- }
- if (result)
- {
- result = (effectiveMaterial() == rhs.effectiveMaterial());
- }
- if (result)
- {
- result = (effectiveBackMaterial() == rhs.effectiveBackMaterial());
- }
- return result;
-}
-
-/*!
- Returns true if this QGLRenderOrder is less than the \a rhs, otherwise
- returns false. Reimplement this function when creating a sub-class of
- QGLRenderOrder.
-
- The default implementation sorts first by effect, second by material (front
- then back).
-
- Sorting by material is ordered by pointer comparison.
-
- Sorting by effect is based on the following order, from lowest to
- highest:
- \list
- \o No effect - hasEffect() == true
- \o Standard effect - ordered by numerical value, eg QGL::FlatColor < QGL::LitMaterial
- \o User effect - ordered by pointer comparison
- \endlist
- So a node with \c{hasEffect() == false} node is \i{less than} a node with
- a custom user effect, for example.
-
- \sa isEqual()
-*/
-bool QGLRenderOrder::isLessThan(const QGLRenderOrder &rhs) const
-{
- bool result = false;
- bool thisHasEffect = effectiveHasEffect();
- bool thatHasEffect = rhs.effectiveHasEffect();
- if (thisHasEffect && thatHasEffect)
- {
- QGLAbstractEffect *eff = effectiveUserEffect();
- if (eff)
- result = (eff < rhs.effectiveUserEffect());
- else
- result = !rhs.effectiveUserEffect() &&
- (effectiveStandardEffect() < rhs.effectiveStandardEffect());
- }
- else
- {
- result = !thisHasEffect;
- }
- if (!result)
- {
- result = (effectiveMaterial() < rhs.effectiveMaterial());
- }
- if (!result)
- {
- result = (effectiveBackMaterial() < rhs.effectiveBackMaterial());
- }
- return result;
-}
-
-/*!
- \fn bool QGLRenderOrder::isValid() const
- Returns true if this is a valid QGLRenderOrder, that is it was
- initialized with a non-null QGLSceneNode.
-*/
-
-/*!
- \fn bool QGLRenderOrder::operator!=(const QGLRenderOrder &rhs) const
- Returns true if this QGLRenderOrder is not equal to the \a rhs, otherwise
- returns false. This function simply returns \c{!isEqual(rhs)}.
-*/
-
-/*!
- \fn bool QGLRenderOrder::bool operator==(const QGLRenderOrder &rhs) const
- Returns true if this QGLRenderOrder is equal to the \a rhs, otherwise
- returns false. This function simply returns \c{isEqual(rhs)}.
-*/
-
-/*!
- \fn bool QGLRenderOrder::operator<(const QGLRenderOrder &rhs) const
- Returns true if this QGLRenderOrder is less than to the \a rhs, otherwise
- returns false. This function simply returns \c{isLessThan(rhs)}.
-*/
-
-/*!
- \fn const QGLSceneNode *QGLRenderOrder::node() const
- Returns a pointer to the scene node for which the render order is held by
- this QGLRenderOrder instance. This is simply the value passed to the
- constructor.
-*/
-
-/*!
- \fn QGLRenderState QGLRenderOrder::state() const
- Returns a pointer to the render state for this order. This is simply the
- value passed to the constructor.
-*/
-
-/*!
- \fn void QGLRenderOrder::setState(const QGLRenderState &state)
- Sets the \a state for this order.
-*/
-
-/*!
- \fn QGLAbstractEffect *QGLRenderOrder::effectiveUserEffect() const
- Returns the effective user effect of the node set for this render
- order, taking into account any effect inherited from parent nodes
- as specified by the render state().
-
- \sa state(), effectiveHasEffect()
-*/
-
-/*!
- \fn QGL::StandardEffect QGLRenderOrder::effectiveStandardEffect() const
- Returns the effective standard effect of the node set for this render
- order, taking into account any effect inherited from parent nodes
- as specified by the render state().
-
- \sa state(), effectiveHasEffect()
-*/
-
-/*!
- \fn QGLMaterial *QGLRenderOrder::effectiveMaterial() const
- Returns the effective material of the node set for this render
- order, taking into account any effect inherited from parent nodes
- as specified by the render state().
-
- \sa state(), effectiveBackMaterial()
-*/
-
-/*!
- \fn QGLMaterial *QGLRenderOrder::effectiveBackMaterial() const
- Returns the effective back material of the node set for this render
- order, taking into account any effect inherited from parent nodes
- as specified by the render state().
-
- \sa state(), effectiveMaterial()
-*/
-
-/*!
- \fn bool QGLRenderOrder::effectiveHasEffect() const
- Returns the effective value of whether an effect is set on the node
- set for this render order, taking into account any effect inherited
- from parent nodes as specified by the render state().
-
- \sa state()
-*/
-
-/*!
- \fn uint qHash(const QGLRenderOrder &order)
- \relates QGLRenderOrder
- Returns a hash value representation of the \a order.
-*/
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QGLRenderOrder &order)
-{
- if (order.isValid())
- dbg << "QGLRenderOrder for node:" << order.node()
- << "-- effect hash:" << order.effectHash()
- << "-- material:" << order.node()->material()
- << "-- back material:" << order.node()->backMaterial();
- else
- dbg << "QGLRenderOrder -- invalid";
- return dbg;
-}
-
-#endif
-
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglrenderorder.h b/src/threed/scene/qglrenderorder.h
deleted file mode 100644
index 272f62f8..00000000
--- a/src/threed/scene/qglrenderorder.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLRENDERORDER_H
-#define QGLRENDERORDER_H
-
-#include "qglscenenode.h"
-#include "qglrenderstate.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLRenderOrder
-{
-public:
- explicit QGLRenderOrder(const QGLSceneNode *node = 0, const QGLRenderState &state = QGLRenderState())
- : m_node(node)
- , m_state(state)
- {
- }
- ~QGLRenderOrder() {}
-
- uint effectHash() const;
- bool isEqual(const QGLRenderOrder &rhs) const;
- bool isLessThan(const QGLRenderOrder &rhs) const;
- inline bool isValid() const;
-
- inline bool operator!=(const QGLRenderOrder &rhs) const;
- inline bool operator==(const QGLRenderOrder &rhs) const;
- inline bool operator<(const QGLRenderOrder &rhs) const;
-
- inline const QGLSceneNode *node() const;
- inline void setState(const QGLRenderState &state);
- inline QGLRenderState state() const;
- inline QGLAbstractEffect *effectiveUserEffect() const;
- inline QGL::StandardEffect effectiveStandardEffect() const;
- inline QGLMaterial *effectiveMaterial() const;
- inline QGLMaterial *effectiveBackMaterial() const;
- inline bool effectiveHasEffect() const;
-private:
- const QGLSceneNode *m_node;
- QGLRenderState m_state;
-};
-
-
-inline bool QGLRenderOrder::isValid() const
-{
- return m_node;
-}
-
-inline bool QGLRenderOrder::operator!=(const QGLRenderOrder &rhs) const
-{
- return !isEqual(rhs);
-}
-
-inline bool QGLRenderOrder::operator==(const QGLRenderOrder &rhs) const
-{
- return isEqual(rhs);
-}
-
-inline bool QGLRenderOrder::operator<(const QGLRenderOrder &rhs) const
-{
- return isLessThan(rhs);
-}
-
-inline const QGLSceneNode *QGLRenderOrder::node() const
-{
- return m_node;
-}
-
-inline QGLRenderState QGLRenderOrder::state() const
-{
- return m_state;
-}
-
-inline void QGLRenderOrder::setState(const QGLRenderState &state)
-{
- m_state = state;
-}
-
-inline QGLAbstractEffect *QGLRenderOrder::effectiveUserEffect() const
-{
- QGLAbstractEffect *result = 0;
- if (m_node)
- {
- if (m_node->userEffect())
- result = m_node->userEffect();
- else if (m_state.userEffect())
- result = m_state.userEffect();
- }
- return result;
-}
-
-inline QGL::StandardEffect QGLRenderOrder::effectiveStandardEffect() const
-{
- QGL::StandardEffect result = QGL::FlatColor;
- if (m_node)
- {
- if (m_node->hasEffect())
- result = m_node->effect();
- else if (m_state.hasEffect())
- result = m_state.standardEffect();
- }
- return result;
-}
-
-inline QGLMaterial *QGLRenderOrder::effectiveMaterial() const
-{
- QGLMaterial *result = 0;
- if (m_node)
- {
- if (m_node->material())
- result = m_node->material();
- else if (m_state.material())
- result = m_state.material();
- }
- return result;
-}
-
-inline QGLMaterial *QGLRenderOrder::effectiveBackMaterial() const
-{
- QGLMaterial *result = 0;
- if (m_node)
- {
- if (m_node->backMaterial())
- result = m_node->backMaterial();
- else if (m_state.backMaterial())
- result = m_state.backMaterial();
- }
- return result;
-}
-
-inline bool QGLRenderOrder::effectiveHasEffect() const
-{
- bool result = false;
- if (m_node)
- {
- if (m_node->hasEffect())
- result = true;
- else
- result = m_state.hasEffect();
- }
- return result;
-}
-
-inline uint qHash(const QGLRenderOrder &order)
-{
- quint64 result = order.effectHash();
- return result ^ reinterpret_cast<quint64>(order.effectiveMaterial());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-#include <QtCore/qdebug.h>
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLRenderOrder &order);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLRENDERORDER_H
diff --git a/src/threed/scene/qglrenderordercomparator.cpp b/src/threed/scene/qglrenderordercomparator.cpp
deleted file mode 100644
index 8d41e0a4..00000000
--- a/src/threed/scene/qglrenderordercomparator.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglrenderordercomparator.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLRenderOrderComparator
- \brief The QGLRenderOrderComparator class compares QGLRenderOrder instances.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- The QGLRenderOrderComparator class works with the QGLRenderSequencer and
- QGLRenderOrder classes to optimize the rendering order of scene nodes.
-
- This class is responsible for comparing QGLRenderOrder instances for
- the QGLRenderSequencer.
-
- Custom render orders may be created by sub-classing QGLRenderOrderComparator
- and reimplementing the following method:
- \list
- \i bool operator()(const QGLRenderOrder &lhs, const QGLRenderOrder &rhs)
- \endlist
-
- Then set an instance of your class onto QGLPainter:
-
- \code
- void MyView::initializeGL(QGLPainter *painter)
- {
- painter->renderSequencer()->setRenderOrderComparator(new MyRenderOrderComparator);
- }
-
- void MyView::paintGL(QGLPainter *painter)
- {
- // draw uses QGLRenderOrder sub-class instances from m_renderOrderFactory
- complexScene->draw(painter);
- }
- \endcode
-
- See the QGLRenderOrder class documentation for more details.
-
- \sa QGLRenderOrder
-*/
-
-/*!
- \fn QGLRenderOrderComparator::QGLRenderOrderComparator()
- Construct a new QGLRenderOrderComparator.
-*/
-
-/*!
- \fn QGLRenderOrderComparator::~QGLRenderOrderComparator()
- Destroys this QGLRenderOrderComparator, recovering any resources.
-*/
-
-/*!
- Returns true if the \a lhs render order is less than the \a rhs;
- otherwise returns false.
-
- Reimplement this function when creating custom render orders.
-*/
-bool QGLRenderOrderComparator::isLessThan(const QGLRenderOrder &lhs, const QGLRenderOrder &rhs)
-{
- bool result = false;
- bool lhsHasEffect = lhs.effectiveHasEffect();
- bool rhsHasEffect = rhs.effectiveHasEffect();
- if (lhsHasEffect && rhsHasEffect)
- {
- QGLAbstractEffect *eff = lhs.effectiveUserEffect();
- if (eff)
- result = (eff < rhs.effectiveUserEffect());
- else
- result = !rhs.effectiveUserEffect() &&
- (lhs.effectiveStandardEffect() < rhs.effectiveStandardEffect());
- }
- else
- {
- result = !lhsHasEffect;
- }
- if (!result)
- {
- result = (lhs.effectiveMaterial() < rhs.effectiveMaterial());
- }
- if (!result)
- {
- result = (lhs.effectiveBackMaterial() < rhs.effectiveBackMaterial());
- }
- return result;
-}
-
-/*!
- Returns true if the \a lhs render order is equal to the \a rhs;
- otherwise returns false.
-
- Reimplement this function when creating custom render orders.
-*/
-bool QGLRenderOrderComparator::isEqualTo(const QGLRenderOrder &lhs, const QGLRenderOrder &rhs)
-{
- bool result = false;
- bool lhsHasEffect = lhs.effectiveHasEffect();
- bool rhsHasEffect = rhs.effectiveHasEffect();
- if (lhsHasEffect && rhsHasEffect)
- {
- QGLAbstractEffect *eff = lhs.effectiveUserEffect();
- if (eff)
- result = (eff == rhs.effectiveUserEffect());
- else
- result = (lhs.effectiveStandardEffect() == rhs.effectiveStandardEffect());
- }
- else
- {
- result = (lhsHasEffect == rhsHasEffect);
- }
- if (result)
- {
- result = (lhs.effectiveMaterial() == rhs.effectiveMaterial());
- }
- if (result)
- {
- result = (lhs.effectiveBackMaterial() == rhs.effectiveBackMaterial());
- }
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglrenderordercomparator.h b/src/threed/scene/qglrenderordercomparator.h
deleted file mode 100644
index 4ede60e9..00000000
--- a/src/threed/scene/qglrenderordercomparator.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLRenderOrderComparator_H
-#define QGLRenderOrderComparator_H
-
-#include "qglrenderorder.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSceneNode;
-
-class Q_QT3D_EXPORT QGLRenderOrderComparator
-{
-public:
- QGLRenderOrderComparator() {}
- virtual ~QGLRenderOrderComparator() {}
-
- virtual bool isLessThan(const QGLRenderOrder &lhs, const QGLRenderOrder &rhs);
- virtual bool isEqualTo(const QGLRenderOrder &lhs, const QGLRenderOrder &rhs);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLRenderOrderComparator_H
diff --git a/src/threed/scene/qglrendersequencer.cpp b/src/threed/scene/qglrendersequencer.cpp
deleted file mode 100644
index 0a739ed0..00000000
--- a/src/threed/scene/qglrendersequencer.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglrendersequencer.h"
-#include "qglrenderorder.h"
-#include "qglpainter.h"
-#include "qglrenderordercomparator.h"
-#include "qglrenderstate.h"
-
-#include <QtCore/qstack.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLRenderSequencer
- \brief The QGLRenderSequencer class orders the rendering of QGLSceneNode instances.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- The QGLRenderSequencer class works with the QGLRenderOrderComparator and
- QGLRenderOrder classes to optimize the rendering order of scene nodes.
-
- In general instances of this class are managed by QGLPainter and it should
- not be necessary to explicitly create or manipulate them.
-
- The render sequencer works by tracking instances of QGLRenderOrder objects
- in a queue. As the scene graph is traversed during a call to a top-level
- node's QGLSceneNode::draw() function, the sequencer adds one QGLRenderOrder
- to the queue for each unique combination of rendering attributes.
-
- The top level scene graph node loops once for each unique combination - it
- does this in QGLSceneNode::draw() by calling nextInSequence(). At
- each iteration, a current QGLRenderOrder is maintained, and only nodes
- matching that order - as determined by \l{QGLRenderOrder::operator==()} -
- are rendered in that pass. Non-matching nodes are added to a queue in the
- order specified by \l{QGLRenderOrder::operator<()}.
-
-
- Once an iteration/pass of
- the scene graph is done, the next order is pulled from the front of the queue
- and the current QGLRenderOrder is set to it.
-
- Since the rendering attributes at a node are a function both of that node,
- and attributes inherited from its parents, and since a given node may appear
- multiple times at different places in the scene, it can thus have different
- attributes and orders in each place. So there is no one-to-one mapping
- between nodes and attributes.
-
- To deal with this, QGLRenderOrder mappings are discovered during rendering.
- There is no discovery pass. First, the initial QGLRenderOrder is lazily set
- when the first geometry is actually drawn to the GPU - latching in that order
- as the first current order. From that point, orders discovered that are
- distinct from the current one are skipped in this rendering pass - by returning
- false from renderInSequence() - and are instead added to the queue for rendering
- on a subsequent pass.
-
- When the final pass has been made, renderInSequence() returns false to the
- top level QGLSceneNode, indicating that looping over passes is complete.
-
- \sa QGLRenderOrder
-*/
-
-class QGLRenderSequencerPrivate
-{
-public:
- QGLRenderSequencerPrivate(QGLPainter *painter);
- ~QGLRenderSequencerPrivate();
- QGLSceneNode *top;
- QLinkedList<QGLRenderOrder> queue;
- QStack<QGLRenderState> stack;
- QSet<QGLRenderOrder> exclude;
- QGLRenderOrder current;
- QGLPainter *painter;
- QGLRenderOrderComparator *compare;
- bool latched;
-};
-
-QGLRenderSequencerPrivate::QGLRenderSequencerPrivate(QGLPainter *painter)
- : top(0)
- , current(QGLRenderOrder())
- , painter(painter)
- , compare(new QGLRenderOrderComparator)
- , latched(false)
-{
-}
-
-QGLRenderSequencerPrivate::~QGLRenderSequencerPrivate()
-{
- delete compare;
-}
-
-/*!
- Construct a new QGLRenderSequencer for the \a painter.
-*/
-QGLRenderSequencer::QGLRenderSequencer(QGLPainter *painter)
- : d(new QGLRenderSequencerPrivate(painter))
-{
-}
-
-/*!
- Sets the render sequencer to operate on \a painter.
-*/
-void QGLRenderSequencer::setPainter(QGLPainter *painter)
-{
- d->painter = painter;
-}
-
-/*!
- Returns the current top node of the rendering tree, or NULL if the
- sequencer has been reset.
-*/
-QGLSceneNode *QGLRenderSequencer::top() const
-{
- return d->top;
-}
-
-/*!
- Sets the current top node of the rendering tree to \a top.
-*/
-void QGLRenderSequencer::setTop(QGLSceneNode *top)
-{
- d->top = top;
-}
-
-/*!
- Reset this sequencer to start from the top of the scene graph again.
- After this call the top() function will return NULL, and any scene
- node passed to the renderInSequence() function will be treated as the
- top of the scene graph. Also effects and materials will be ignored
- until latched in - QGLPainter::draw() will call latch() to achieve this.
-
- \sa top()
-*/
-void QGLRenderSequencer::reset()
-{
- d->top = 0;
- d->latched = false;
- d->exclude.clear();
- d->stack.clear();
- d->current = QGLRenderOrder();
-}
-
-/*!
- Returns true if there is a next rendering state in the queue; and if there
- is a new order will be pulled from the queue, and its rendering attributes
- - materials, effects and so on - will be applied to the painter for this
- sequencer. Returns false when no more rendering states are queued and
- scene is completely rendered.
-*/
-bool QGLRenderSequencer::nextInSequence()
-{
- bool nextAvailable = true;
- if (d->queue.size() > 0)
- {
- // process thru next render order
- d->current = d->queue.takeFirst();
- }
- else
- {
- // end top level loop
- nextAvailable = false;
- }
- return nextAvailable;
-}
-
-/*!
- Returns true, when this \a node should be rendered, in the order dictated
- by QGLRenderOrder objects generated by the current render order Comparator.
- The \a node must be non-NULL.
-
- When this function returns false, indicating that rendering should be
- skipped for the current pass, a check is made to ensure that a state object
- for this nodes rendering attributes is queued up for a later pass.
-
- To customize the ordering, reimplement QGLRenderOrder and
- QGLRenderOrderComparator; then set the custom Comparator onto the current
- painter using setcompare().
-
- \sa reset(), top(), nextInSequence()
-*/
-bool QGLRenderSequencer::renderInSequence(QGLSceneNode *node)
-{
- Q_ASSERT(node);
- Q_ASSERT(d->top);
- bool doRender = true;
- QGLRenderState state;
- if (!d->stack.empty())
- state = d->stack.top();
- QGLRenderOrder o(node, state);
- if (!d->current.isValid())
- d->current = o;
- if (d->latched && !d->compare->isEqualTo(o, d->current))
- {
- if (!d->exclude.contains(o))
- insertNew(o);
- doRender = false;
- }
- else
- {
- if (!d->latched)
- d->exclude.insert(o);
- }
- return doRender;
-}
-
-/*!
- Marks the render state for the \a node as started for this rendering pass. Call
- this before rendering \a node, or any child nodes of \a node.
-
- Once the rendering state is no longer valid, call endState().
-
- To actually apply the effective state, as inherited from previous calls to
- beginState() call the applyState() function.
-
- \sa endState(), applyState()
-*/
-void QGLRenderSequencer::beginState(QGLSceneNode *node)
-{
- QGLRenderState state;
- if (!d->stack.empty())
- state = d->stack.top();
- state.updateFrom(node);
- d->stack.push(state);
-}
-
-/*!
- Marks the render state for the \a node as done for this rendering pass.
-
- If a node has called beginState(), then this function must be called to maintain
- the rendering stack. If this function call is not matched by a previous
- beginState() call undefined behaviour may result. In debug mode it may assert.
-
- \sa beginState(), applyState()
-*/
-void QGLRenderSequencer::endState(QGLSceneNode *node)
-{
-#ifndef QT_NO_DEBUG_STREAM
- const QGLSceneNode *n = d->stack.top().node();
- Q_UNUSED(n);
- Q_UNUSED(node);
- Q_ASSERT(n == node);
-#endif
- d->stack.pop();
-}
-
-/*!
- Applies the current rendering state to the painter for this sequencer.
-
- \sa beginState(), endState()
-*/
-void QGLRenderSequencer::applyState()
-{
- d->latched = true;
- QGLRenderState s = d->stack.top();
- if (s.hasEffect() && !d->painter->isPicking())
- {
- if (s.userEffect())
- {
- if (d->painter->userEffect() != s.userEffect())
- d->painter->setUserEffect(s.userEffect());
- }
- else
- {
- if (d->painter->userEffect() ||
- d->painter->standardEffect() != s.standardEffect())
- d->painter->setStandardEffect(s.standardEffect());
- }
- }
- if (s.material() && !d->painter->isPicking())
- {
- QGLMaterial *mat = s.material();
- if (1) //FIXME: d->painter->faceMaterial(QGL::FrontFaces) != mat)
- {
- d->painter->setFaceMaterial(QGL::FrontFaces, mat);
- int texUnit = 0;
- for (int i = 0; i < mat->textureLayerCount(); ++i)
- {
- QGLTexture2D *tex = mat->texture(i);
- if (tex)
- {
- d->painter->glActiveTexture(GL_TEXTURE0 + texUnit);
- tex->bind();
- ++texUnit;
- }
- }
- }
- }
-}
-
-void QGLRenderSequencer::insertNew(const QGLRenderOrder &order)
-{
- QLinkedList<QGLRenderOrder>::iterator it = d->queue.begin();
- for ( ; it != d->queue.end(); ++it)
- {
- const QGLRenderOrder o = *it;
- if (d->compare->isLessThan(order, o))
- break;
- }
- d->queue.insert(it, order);
- d->exclude.insert(order);
-}
-
-/*!
- Returns the current render order comparator. By default this is an
- instance of the base class QGLRenderOrderComparator.
-
- \sa setComparator()
-*/
-QGLRenderOrderComparator *QGLRenderSequencer::comparator() const
-{
- return d->compare;
-}
-
-/*!
- Sets the current render order \a comparator. This is only needed if a
- custom rendering order is to be created. The argument \a comparator
- must be non-null, or undefined behaviour will result.
-
- Any existing current comparator is destroyed.
-
- \sa renderInSequence(), comparator()
-*/
-void QGLRenderSequencer::setComparator(QGLRenderOrderComparator *comparator)
-{
- Q_ASSERT(comparator);
- delete d->compare;
- d->compare = comparator;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglrendersequencer.h b/src/threed/scene/qglrendersequencer.h
deleted file mode 100644
index 55e7f1d7..00000000
--- a/src/threed/scene/qglrendersequencer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLRENDERSEQUENCER_H
-#define QGLRENDERSEQUENCER_H
-
-#include <QtCore/qlinkedlist.h>
-#include <QtCore/qset.h>
-
-#include "qglrenderorder.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSceneNode;
-class QGLPainter;
-class QGLRenderOrderComparator;
-class QGLRenderSequencerPrivate;
-
-class Q_QT3D_EXPORT QGLRenderSequencer
-{
-public:
- explicit QGLRenderSequencer(QGLPainter *painter);
- void setPainter(QGLPainter *painter);
- bool renderInSequence(QGLSceneNode *node);
- bool nextInSequence();
- void beginState(QGLSceneNode *node);
- void endState(QGLSceneNode *node);
- void reset();
- QGLSceneNode *top() const;
- void setTop(QGLSceneNode *top);
- QGLRenderOrderComparator *comparator() const;
- void setComparator(QGLRenderOrderComparator *comparator);
- void applyState();
-private:
- void insertNew(const QGLRenderOrder &order);
-
- QGLRenderSequencerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGLRENDERSEQUENCER_H
diff --git a/src/threed/scene/qglrenderstate.cpp b/src/threed/scene/qglrenderstate.cpp
deleted file mode 100644
index 4414dbce..00000000
--- a/src/threed/scene/qglrenderstate.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglrenderstate.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLRenderState
- \brief The QGLRenderState class encapsulates the states of a rendering pass.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- The QGLRenderState class works with the QGLRenderOrder class to optimize
- the rendering order of scene nodes.
-
- In general instances of this class are managed by the render sequencer
- and it should not be necessary to explicitly create or manipulate them.
-
- A QGLRenderState instance encapsulates rendering properties for a given
- path through the rendering process. The state includes properties such as
- effects, and materials; which may either be directly set on a scene node,
- or inherited from its parents.
-
- QGLRenderState may be subclassed in advanced applications to provide a
- different inheritance pattern for rendering properties - reimplement the
- updateFrom() function to do this. The default implementation simply sets
- an effect on the state if the argument node has an effect (found by
- calling the QGLSceneNode::hasEffect() function), and sets a material on
- the state if the node has a non-null material; otherwise the existing
- state is left as it is.
-
- The render sequencer will ensure that the relevant render state is set
- onto the painter at the beginning of the pass which renders all nodes
- with that state.
-
- \sa QGLRenderOrder
-*/
-
-class QGLRenderStatePrivate : public QSharedData
-{
-public:
- QGLRenderStatePrivate();
- ~QGLRenderStatePrivate();
- QGLRenderStatePrivate *clone() const;
-
- QBasicAtomicInt ref;
-
- bool hasEffect;
- QGLMaterial *material;
- QGLMaterial *backMaterial;
- QGL::StandardEffect standardEffect;
- QGLAbstractEffect *userEffect;
- const QGLSceneNode *node;
-};
-
-QGLRenderStatePrivate::QGLRenderStatePrivate()
- : hasEffect(false)
- , material(0)
- , backMaterial(0)
- , standardEffect(QGL::FlatColor)
- , userEffect(0)
- , node(0)
-{
- ref = 0;
-}
-
-QGLRenderStatePrivate::~QGLRenderStatePrivate()
-{
-}
-
-QGLRenderStatePrivate *QGLRenderStatePrivate::clone() const
-{
- QGLRenderStatePrivate *r = new QGLRenderStatePrivate;
- r->hasEffect = hasEffect;
- r->material = material;
- r->backMaterial = backMaterial;
- r->standardEffect = standardEffect;
- r->userEffect = userEffect;
- r->node = node;
- return r;
-}
-
-/*!
- Creates a new QGLRenderState empty of any values.
-*/
-QGLRenderState::QGLRenderState()
- : d(0)
-{
-}
-
-/*!
- Creates a new QGLRenderState as a copy of \a other
-*/
-QGLRenderState::QGLRenderState(const QGLRenderState &other)
- : d(other.d)
-{
- if (d)
- d->ref.ref();
-}
-
-/*!
- Destroys this QGLRenderState recovering and resources.
-*/
-QGLRenderState::~QGLRenderState()
-{
- if (d && !d->ref.deref())
- delete d;
-}
-
-/*!
- Assigns this QGLRenderState to be a copy of \a rhs.
-*/
-QGLRenderState &QGLRenderState::operator=(const QGLRenderState &rhs)
-{
- if (d != rhs.d)
- {
- if (d && !d->ref.deref())
- delete d;
- d = rhs.d;
- if (d)
- d->ref.ref();
- }
- return *this;
-}
-
-/*!
- Sets the values of this QGLRenderState from the \a node, where
- the node has a value. For example if the \a node has an effect
- but no material, then this state will have its effect changed to
- that of the node, but this state's material will be unchanged.
-*/
-void QGLRenderState::updateFrom(const QGLSceneNode *node)
-{
- detach();
- if (node->hasEffect())
- {
- d->hasEffect = true;
- if (node->userEffect())
- d->userEffect = node->userEffect();
- else
- d->standardEffect = node->effect();
- }
- if (node->material())
- d->material = node->material();
- if (node->backMaterial())
- d->backMaterial = node->backMaterial();
- d->node = node;
-}
-
-/*!
- Returns the user effect stored on this QGLRenderState, or null if no
- user effect has been set. The default value is null.
-*/
-QGLAbstractEffect *QGLRenderState::userEffect() const
-{
- QGLAbstractEffect *e = 0;
- if (d)
- e = d->userEffect;
- return e;
-}
-
-/*!
- Returns the standard effect stored on this QGLRenderState. The
- default value is QGL::FlatColor. To determine if an effect has
- been specifically set call hasEffect().
-*/
-QGL::StandardEffect QGLRenderState::standardEffect() const
-{
- QGL::StandardEffect e = QGL::FlatColor;
- if (d)
- e = d->standardEffect;
- return e;
-}
-
-/*!
- Returns true is there is a valid effect on this QGLRenderState. The
- default value is false.
-*/
-bool QGLRenderState::hasEffect() const
-{
- bool r = false;
- if (d)
- r = d->hasEffect;
- return r;
-}
-
-/*!
- Returns the material stored on this QGLRenderState, or null if no
- material has been set. The default value is null.
-*/
-QGLMaterial *QGLRenderState::material() const
-{
- QGLMaterial *m = 0;
- if (d)
- m = d->material;
- return m;
-}
-
-/*!
- Returns the back material stored on this QGLRenderState, or null if no
- back material has been set. The default value is null.
-*/
-QGLMaterial *QGLRenderState::backMaterial() const
-{
- QGLMaterial *m = 0;
- if (d)
- m = d->backMaterial;
- return m;
-}
-
-/*!
- Returns the node used to populate this QGLRenderState.
-*/
-const QGLSceneNode *QGLRenderState::node() const
-{
- const QGLSceneNode *s = 0;
- if (d)
- s = d->node;
- return s;
-}
-
-/*!
- Returns true if this is a valid representation of a render state, that
- is if it has ever been updated from a node; and false otherwise.
-*/
-bool QGLRenderState::isValid() const
-{
- if (d && d->node)
- return true;
- return false;
-}
-
-/*!
- \fn bool QGLRenderState::operator==(const QGLRenderState &rhs) const
- Returns true if this state is equal to \a rhs, that is if each of the
- materials, effects and values are equal to those of \a rhs.
-*/
-void QGLRenderState::detach()
-{
- if (!d) // lazy creation of data block
- {
- d = new QGLRenderStatePrivate;
- d->ref.ref();
- }
- else
- {
- if (d->ref > 1) // being shared, must detach
- {
- QGLRenderStatePrivate *temp = d->clone();
- d->ref.deref();
- d = temp;
- d->ref.ref();
- }
- }
-}
-
-/*!
- Returns a hash value representing this state.
-*/
-uint QGLRenderState::hash() const
-{
- const QByteArray bytes((const char *)d, sizeof(d));
- return qHash(bytes);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLRenderState &order)
-{
- dbg << "QGLRenderState" << &order << "-- user effect:" << order.userEffect()
- << "-- standardEffect:" << order.standardEffect()
- << "-- hasEffect:" << order.hasEffect()
- << "-- material:" << order.material()
- << "-- back material:" << order.backMaterial()
- << "-- node:" << order.node();
- return dbg;
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglrenderstate.h b/src/threed/scene/qglrenderstate.h
deleted file mode 100644
index 2007f19b..00000000
--- a/src/threed/scene/qglrenderstate.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLRENDERSTATE_H
-#define QGLRENDERSTATE_H
-
-#include "qglnamespace.h"
-#include "qglscenenode.h"
-
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLAbstractEffect;
-class QGLMaterial;
-
-class QGLRenderStatePrivate;
-
-class Q_QT3D_EXPORT QGLRenderState
-{
-public:
- QGLRenderState();
- QGLRenderState(const QGLRenderState &other);
- virtual ~QGLRenderState();
- QGLRenderState &operator=(const QGLRenderState &rhs);
- virtual void updateFrom(const QGLSceneNode *node);
- QGLAbstractEffect *userEffect() const;
- QGL::StandardEffect standardEffect() const;
- bool hasEffect() const;
- QGLMaterial *material() const;
- QGLMaterial *backMaterial() const;
- const QGLSceneNode *node() const;
- uint hash() const;
- bool operator==(const QGLRenderState &rhs) const
- {
- if (userEffect() != rhs.userEffect())
- return false;
- if (standardEffect() != rhs.standardEffect())
- return false;
- if (hasEffect() != rhs.hasEffect())
- return false;
- if (material() != rhs.material())
- return false;
- if (backMaterial() != rhs.backMaterial())
- return false;
- return true;
- }
- bool isValid() const;
-private:
- void detach();
- QGLRenderStatePrivate *d;
-};
-
-inline uint qHash(const QGLRenderState &s)
-{
- return s.hash();
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-#include <QtCore/qdebug.h>
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLRenderState &order);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QGLRENDERSTATE_H
diff --git a/src/threed/scene/qglsceneformatplugin.cpp b/src/threed/scene/qglsceneformatplugin.cpp
deleted file mode 100644
index 787d3e45..00000000
--- a/src/threed/scene/qglsceneformatplugin.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsceneformatplugin.h"
-#include "qdownloadmanager.h"
-#include "qabstractdownloadmanager.h"
-#include "qthreadeddownloadmanager.h"
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLSceneFormatHandler
- \brief The QGLSceneFormatHandler class defines the common format I/O interface for loading 3D scene formats.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- \sa QGLSceneFormatPlugin
-*/
-
-class QGLSceneFormatHandlerPrivate
-{
-public:
- QGLSceneFormatHandlerPrivate()
- {
- device = 0;
- m_scene = 0;
- }
-
- QIODevice *device;
- QString format;
- QUrl url;
- QGLAbstractScene *m_scene;
-};
-
-/*!
- Constructs a 3D scene format handler.
-*/
-QGLSceneFormatHandler::QGLSceneFormatHandler()
-{
- d_ptr = new QGLSceneFormatHandlerPrivate();
- m_downloadManager = 0;
-}
-
-/*!
- Destroys this 3D scene format handler.
-*/
-QGLSceneFormatHandler::~QGLSceneFormatHandler()
-{
- delete d_ptr;
-}
-
-/*!
- Returns the device currently assigned to the 3D scene format handler.
- Returns null if no device has been assigned.
-
- \sa setDevice()
-*/
-QIODevice *QGLSceneFormatHandler::device() const
-{
- return d_ptr->device;
-}
-
-/*!
- Sets the device for this 3D scene format handler to \a device.
- The handler will use this device when reading 3D scenes.
-
- The device can only be set once and must be set before calling
- read(). If you need to read multiple files, construct multiple
- instances of the appropriate QGLSceneFormatHandler subclass.
-
- \sa device()
-*/
-void QGLSceneFormatHandler::setDevice(QIODevice *device)
-{
- d_ptr->device = device;
-}
-
-/*!
- Returns the format that is currently assigned to this 3D scene
- format handler. Returns an empty string if no format has been assigned.
-
- \sa setFormat()
-*/
-QString QGLSceneFormatHandler::format() const
-{
- return d_ptr->format;
-}
-
-/*!
- Sets the format of this 3D scene format handler to \a format.
-
- \sa format()
-*/
-void QGLSceneFormatHandler::setFormat(const QString& format)
-{
- d_ptr->format = format;
-}
-
-/*!
- Returns the url of the data provided by device(). This is
- typically used when the data in device() refers to additional
- files that need to be located relative to the original
- directory.
-
- \sa setUrl()
-*/
-QUrl QGLSceneFormatHandler::url() const
-{
- return d_ptr->url;
-}
-
-/*!
- Sets the \a url of the data provided by device().
-
- \sa url()
-*/
-void QGLSceneFormatHandler::setUrl(const QUrl& url)
-{
- d_ptr->url = url;
-}
-
-/*!
- Decodes and applies \a options to this handler. Generally this will be
- called by the QGLAbstractScene::loadScene() method prior to reading
- the model data with read() or download(). Exactly what the string value may contain
- and the meaning of the encoded options depends on each individual plugin.
-
- This default implementation simply does nothing.
-*/
-void QGLSceneFormatHandler::decodeOptions(const QString &options)
-{
- Q_UNUSED(options);
-}
-
-/*!
- \fn QGLAbstractScene *QGLSceneFormatHandler::read()
-
- Reads a 3D scene from device() and returns it. Returns null if
- the format of device() is invalid and a scene could not be read.
-*/
-
-/*!
- \fn QGLAbstractScene *QGLSceneFormatHandler::download()
-
- Reads a 3D scene from a url and returns a stub to it which can be used
- the application, and will be updated with the full scene later.
-
- Returns NULL if the scene could not be created.
-*/
-
-/*!
- \class QGLSceneFormatFactoryInterface
- \brief The QGLSceneFormatFactoryInterface class provides the factory interface for QGLSceneFormatPlugin.
- \internal
-*/
-
-/*!
- \class QGLSceneFormatPlugin
- \brief The QGLSceneFormatPlugin class defines an interface for loading 3D object and scene formats.
- \ingroup qt3d
- \ingroup qt3d::scene
-
- \sa QGLSceneFormatHandler
-*/
-
-/*!
- Constructs a 3D scene format plugin with the given \a parent. This is
- invoked automatically by the Q_EXPORT_PLUGIN2() macro.
-*/
-QGLSceneFormatPlugin::QGLSceneFormatPlugin(QObject *parent)
- : QObject(parent)
-{
- //do nothing
-}
-
-/*!
- Destroys this 3D scene format plugin. This is invoked automatically
- when the plugin is unloaded.
-*/
-QGLSceneFormatPlugin::~QGLSceneFormatPlugin()
-{
- //do nothing
-}
-
-/*!
- Initiates download of the specified scene. The scene must have been
- previously specified with URL, options, format, and so on. This
- function will then create a QGLAbstractDownloadManager instance and
- submit the network request for the scene.
-
- The resultant data will be handled by the downloadComplete() slot.
-*/
-void QGLSceneFormatHandler::downloadScene()
-{
- if (!m_downloadManager) {
- if (getenv(QT3D_MULTITHREAD)) {
- //Download in a multithreaded environment
- m_downloadManager = new QThreadedDownloadManager();
- } else {
- //Download in a single threaded environment
- m_downloadManager = new QDownloadManager();
- }
- connect(m_downloadManager,SIGNAL(downloadComplete(QByteArray)), this, SLOT(downloadComplete(QByteArray)));
- }
-
- if (!m_downloadManager->beginDownload(QUrl(url().toString()))) {
- qWarning("Unable to issue asset download request.");
- }
-}
-
-/*!
- Set the pointer for the scene \a theScene currently being processed.
- This is specifically used during network loading.
-*/
-void QGLSceneFormatHandler::setScene(QGLAbstractScene *theScene)
-{
- d_ptr->m_scene = theScene;
-}
-
-/*!
- Get the pointer for the scene currently being processed. This is
- specifically used during network loading.
-*/
-QGLAbstractScene * QGLSceneFormatHandler::getScene() const
-{
- return d_ptr->m_scene;
-}
-
-/*!
- This function should be called when the download of a remotely hosted
- scene is complete. The \a sceneData will contain the relevant data for
- the scene.
-
- The user is required to reimplement this if they intend to support network
- loading of scenes in their plugin.
-*/
-void QGLSceneFormatHandler::downloadComplete(QByteArray sceneData)
-{
- Q_UNUSED(sceneData);
- //unused - re-implement if you intend to support network
- //loading of model files.
-}
-
-/*!
- Called at the end of the read() and download() functions, this function
- completes any extra cleanup required, and sets the QGLSceneFormatHandler
- it belongs to as being ready for deletion when the main event loop is next
- processed.
-*/
-void QGLSceneFormatHandler::finalize()
- {
- deleteLater();
- }
-
-/*!
- \fn QStringList QGLSceneFormatPlugin::keys() const
-
- Returns the list of format keys this plugin supports. These keys
- are usually the names of the 3D scene formats that are implemented in
- the plugin (e.g., "3ds", "obj", etc). The returned elements must
- be in lower case.
-
- \sa create()
-*/
-
-/*!
- \fn QGLSceneFormatHandler *QGLSceneFormatPlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-
- Creates and returns a QGLSceneFormatHandler for handling the data in
- \a device according to \a format. The \a url specifies the original
- location of the data for resolving relative resource references.
-
- \sa keys()
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglsceneformatplugin.h b/src/threed/scene/qglsceneformatplugin.h
deleted file mode 100644
index 13ac067d..00000000
--- a/src/threed/scene/qglsceneformatplugin.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSCENEFORMATPLUGIN_H
-#define QGLSCENEFORMATPLUGIN_H
-
-#include "qt3dglobal.h"
-#include <QObject>
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLAbstractScene;
-class QGLSceneFormatHandlerPrivate;
-class QAbstractDownloadManager;
-
-class Q_QT3D_EXPORT QGLSceneFormatHandler : public QObject
-{
- Q_OBJECT
-public:
- QGLSceneFormatHandler();
- virtual ~QGLSceneFormatHandler();
-
- QIODevice *device() const;
- void setDevice(QIODevice *device);
-
- QString format() const;
- void setFormat(const QString& format);
-
- QUrl url() const;
- void setUrl(const QUrl& url);
-
- virtual QGLAbstractScene *read() = 0;
- virtual QGLAbstractScene *download() = 0;
-
- virtual void decodeOptions(const QString &options);
-
- void finalize();
-
- void downloadScene();
-
-public slots:
- virtual void downloadComplete(QByteArray sceneData);
-protected:
- void setScene(QGLAbstractScene *theScene);
- QGLAbstractScene * getScene() const;
-
- QAbstractDownloadManager *m_downloadManager;
-private:
- QGLSceneFormatHandlerPrivate *d_ptr;
-};
-
-struct Q_QT3D_EXPORT QGLSceneFormatFactoryInterface : public QFactoryInterface
-{
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format = QString()) const = 0;
-};
-
-#define QGLSceneFormatFactoryInterface_iid \
- "com.trolltech.Qt.QGLSceneFormatFactoryInterface"
-Q_DECLARE_INTERFACE(QGLSceneFormatFactoryInterface, QGLSceneFormatFactoryInterface_iid)
-
-class Q_QT3D_EXPORT QGLSceneFormatPlugin : public QObject, public QGLSceneFormatFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGLSceneFormatFactoryInterface:QFactoryInterface)
-public:
- explicit QGLSceneFormatPlugin(QObject *parent = 0);
- virtual ~QGLSceneFormatPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format = QString()) const = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/scene/qglscenenode.cpp b/src/threed/scene/qglscenenode.cpp
deleted file mode 100644
index 545793fb..00000000
--- a/src/threed/scene/qglscenenode.cpp
+++ /dev/null
@@ -1,1884 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglabstractscene.h"
-#include "qglscenenode.h"
-#include "qglscenenode_p.h"
-#include "qglpicknode.h"
-#include "qglpainter.h"
-#include "qgeometrydata.h"
-#include "qglmaterialcollection.h"
-#include "qglrendersequencer.h"
-#include "qglabstracteffect.h"
-#include "qgraphicstransform3d.h"
-
-#ifndef QT_NO_DEBUG_STREAM
-#include "qglmaterialcollection.h"
-#include "qgltexture2d.h"
-#endif
-
-#include <QtGui/qmatrix4x4.h>
-#if !defined(QT_NO_THREAD)
-#include <QtCore/qthread.h>
-#include <QtGui/qapplication.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLSceneNode
- \brief The QGLSceneNode class defines a node in a 3D scene.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::scene
-
- QGLSceneNode represents one component of a scene. The QGLSceneNode
- class manages materials, effects and transformations for itself and
- for its child nodes.
-
- As a general approach to 3D applications, a tree of QGLSceneNodes may
- be constructed, geometry added to them, materials and transformations
- applied, all during application initialization; and then by simply
- calling the draw() function the scene is easily rendered for each frame.
-
- \section1 Geometry
-
- Multiple QGLSceneNodes can reference the same geometry, whilst
- applying different transformations and treatments to it. Since
- QGLSceneNode is a QObject sub class it cannot be copied directly, so
- instead use the clone() function for this purpose.
-
- A scene node allows referencing into sub-parts of geometry, via the start
- and count properties.
-
- The start index is an offset into the geometry at which drawing will start.
- The default start index is 0, so that drawing will start from the beginning
- of the geometry. The count dictates how many vertices will be drawn. The
- default count is 0, which instructs the underlying geometry to draw all
- vertices.
-
- A node may have no geometry, that is \c{geometry().count() == 0}. This is
- useful for example to have one node controlling or collecting together
- several child nodes to be manipulated as a unit.
-
- \section1 Materials
-
- Also a node may have a local material. This allows drawing the same geometry
- with different materials (which includes different textures).
-
- When accessing a QGLSceneNode via QML, or for simple applications, the
- pointer based material functions are convenient and intuitive, saving the
- trouble of adding the material pointer to the correct palette:
- \list
- \i material()
- \i setMaterial()
- \i backMaterial()
- \i setBackMaterial()
- \endlist
-
- For more complex applications; for example building model loaders, or for
- larger scenes; where you need to explicitly manage materials via a palette,
- use the index based functions:
- \list
- \i materialIndex()
- \i setMaterialIndex()
- \i backMaterialIndex()
- \i setBackMaterialIndex()
- \endlist
-
- The behaviour of both with respect to faces is the same - if a material()
- is specified but no backMaterial() is specified, then the material() is
- applied to both faces; if both material() and backMaterial() are non-null
- then they are applied to their specific faces.
-
- \section1 Transformations
-
- Typically the local transformation matrix is set by the process that
- constructed the node: in the case of an imported model, it is likely
- to have been specified by the model file. To make individual changes
- to the location or orientation of this node, use the position() and
- transforms() properties.
-
- \section1 Scene Graph
-
- Use childNodes() to obtain the list of child nodes, and add and remove
- child nodes by the addNode() and removeNode() methods. If a QGLSceneNode
- is constructed with a QGLSceneNode parent, then addNode() will be
- called implicitly on the parent.
-
- A child may be a child multiple times, a child may be under more than one
- parent, and several parents may reference the same child. There is however
- no protection against cycles, so a child must not be a parent of itself,
- even if indirectly.
-
- A child node for the purposes of rendering means a child added via the
- addNode() method. The default QGLSceneNode constructor will check to
- see if its parent is a QGLSceneNode and add itself via the addNode()
- function if it is.
-
- To help debug a scene, use the qDumpScene() function to get a printout
- on stderr of the entire structure of the scene below the argument node.
-
- \section1 Debugging Lighting Normals
-
- The ViewNormals option is an advanced feature for use when inspecting
- and debugging models or geometry in a scene. The lighting normals
- are displayed as a straight line from the vertex pointing in
- the direction of the lighting normal. This is useful for
- example to show where normals are inverted or wrongly
- calculated.
-
- The setting of the ViewNormals flag is not propagated to child nodes,
- instead set the flag to true for the node or nodes where its
- needed. To set the flag on all child nodes use code like:
-
- \code
- foreach (QGLSceneNode *node, scene.allChildren())
- node->setNormalViewEnabled(true);
- \endcode
-
- \image spiky-teapot.png
-
- \sa QGLAbstractScene
-*/
-
-/*!
- \enum QGLSceneNode::Option
- This enum defines option flags for QGLSceneNode. By default the none of the flags
- are set, so the options() function returns QGLSceneNode::NoOptions
-
- \value NoOptions Do not enable any QGLSceneNode options.
- \value CullBoundingBox Perform a cull using boundingBox() before
- attempting to draw the geometry().
- \value ViewNormals Enables the display of lighting normals for
- debugging purposes.
- \value ReportCulling Send a signal when an object is displayed or culled.
- \value HideNode Hide this node so it, and all its children, are excluded from rendering.
- \sa setOptions()
-*/
-
-/*!
- Constructs a new scene node and attaches it to \a parent. If parent is
- a QGLSceneNode then this node is added to it as a child.
-*/
-QGLSceneNode::QGLSceneNode(QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLSceneNodePrivate())
-{
- QGLSceneNode *sceneParent = qobject_cast<QGLSceneNode*>(parent);
- if (sceneParent)
- sceneParent->addNode(this);
-}
-
-/*!
- \internal
- Used by clone().
-*/
-QGLSceneNode::QGLSceneNode(QGLSceneNodePrivate *d, QObject *parent)
- : QObject(parent)
- , d_ptr(d)
-{
- QGLSceneNode *sceneParent = qobject_cast<QGLSceneNode*>(parent);
- if (sceneParent)
- sceneParent->addNode(this);
-}
-
-/*!
- Constructs a new scene node referencing \a geometry and attaches it to
- \a parent. If parent is a QGLSceneNode then this node is added to it
- as a child.
-*/
-QGLSceneNode::QGLSceneNode(const QGeometryData &geometry, QObject *parent)
- : QObject(parent)
- , d_ptr(new QGLSceneNodePrivate())
-{
- Q_D(QGLSceneNode);
- d->geometry = geometry;
- QGLSceneNode *sceneParent = qobject_cast<QGLSceneNode*>(parent);
- if (sceneParent)
- sceneParent->addNode(this);
-}
-
-/*!
- Destroys this scene node.
-*/
-QGLSceneNode::~QGLSceneNode()
-{
- Q_D(QGLSceneNode);
-
- // Detach ourselves from our children. The children will be
- // deleted separately when their QObject::parent() deletes them.
- for (int index = 0; index < d->childNodes.count(); ++index)
- d->childNodes.at(index)->d_ptr->parentNodes.removeOne(this);
-
- // Detach ourselves from our remaining parents, and notify them
- // to update their bounding boxes. This won't be needed if we
- // are recursively destroying a tree of nodes because the parent
- // already detached from this node above.
- for (int index = 0; index < d->parentNodes.count(); ++index) {
- QGLSceneNode *parent = d->parentNodes.at(index);
- parent->d_ptr->childNodes.removeOne(this);
- parent->invalidateBoundingBox();
- }
-}
-
-/*!
- Returns the drawing options associated with this node.
- The default is 0 (no options set).
-
- \sa setOptions(), setOption()
-*/
-QGLSceneNode::Options QGLSceneNode::options() const
-{
- Q_D(const QGLSceneNode);
- return d->options;
-}
-
-/*!
- \qmlproperty enumeration QGLSceneNode::options
-
- Defines the settings of various options configurabled on
- nodes in the mesh.
-
- \list
- \o NoOptions Use no options. This is the default.
- \o CullBoundingBox Use the camera position to cull the whole node if possible.
- \o ViewNormals Turn on normals debugging mode visually depict lighting normals.
- \o ReportCulling Send a signal when an object is displayed or culled.
- \endlist
-*/
-
-/*!
- Sets the drawing \a options associated with this node.
-
- \sa options(), setOption()
-*/
-void QGLSceneNode::setOptions(QGLSceneNode::Options options)
-{
- Q_D(QGLSceneNode);
- if (d->options != options) {
- d->options = options;
- emit updated();
- }
-}
-
-/*!
- Enables or disables \a option according to \a value.
-
- \sa options(), setOptions()
-*/
-void QGLSceneNode::setOption(QGLSceneNode::Option option, bool value)
-{
- Q_D(QGLSceneNode);
- QGLSceneNode::Options opts = d->options;
- if (value)
- opts |= option;
- else
- opts &= ~option;
- if (d->options != opts) {
- d->options = opts;
- emit updated();
- }
-}
-
-/*!
- Returns the geometry associated with this node, or a null QGeometryData
- if no geometry has been associated with it.
-
- \sa setGeometry()
-*/
-QGeometryData QGLSceneNode::geometry() const
-{
- Q_D(const QGLSceneNode);
- return d->geometry;
-}
-
-/*!
- Sets the geometry associated with this node to be \a geometry.
- Typically the \a geometry will be some type of mesh object. The
- default implementation of the QGLSceneNode::draw() method will call
- the geometry's draw() method.
-
- \sa geometry()
-*/
-void QGLSceneNode::setGeometry(QGeometryData geometry)
-{
- Q_D(QGLSceneNode);
- d->geometry = geometry;
- emit updated();
-}
-
-/*!
- Returns a bounding box for the portion of the geometry referenced by
- this scene node. If the value of start() is 0, and count() is the same
- as geometry()->size() then the bounding box will be the same as
- geometry()->boundingBox(). However if the scene node only references
- some part of the geometry, a bounding box for this section is calculated.
-
- If this scene node has child nodes then the bounding box will be the
- calculated union of the bounding box for this nodes geometry (if any) and
- the bounding boxes of the children.
-
- The calculated value is cached and returned on subsequent calls, but
- could be expensive to calculate initially.
-*/
-QBox3D QGLSceneNode::boundingBox() const
-{
- Q_D(const QGLSceneNode);
- if (d->boxValid)
- return d->bb;
- d->bb = QBox3D();
- if (d->geometry.count() > 0)
- {
- if (d->start == 0 && (d->count == d->geometry.count() || d->count == 0))
- {
- d->bb = d->geometry.boundingBox();
- }
- else
- {
- QGL::IndexArray indices = d->geometry.indices();
- for (int i = d->start; i < (d->start + d->count); ++i)
- {
- int ix = indices.at(i);
- d->bb.unite(d->geometry.vertexAt(ix));
- }
- }
- }
- QList<QGLSceneNode*>::const_iterator it = d->childNodes.constBegin();
- for ( ; it != d->childNodes.constEnd(); ++it)
- {
- QGLSceneNode *n = *it;
- QBox3D b = n->boundingBox();
- d->bb.unite(b);
- }
- d->bb.transform(transform());
- d->boxValid = true;
- return d->bb;
-}
-
-// Calculate the resulting matrix from the position, local transform,
-// and list of transforms.
-QMatrix4x4 QGLSceneNode::transform() const
-{
- Q_D(const QGLSceneNode);
- QMatrix4x4 m;
- if (!d->translate.isNull())
- m.translate(d->translate);
- if (!d->localTransform.isIdentity())
- m *= d->localTransform;
- for (int index = d->transforms.size() - 1; index >= 0; --index)
- d->transforms.at(index)->applyTo(&m);
- return m;
-}
-
-/*!
- Returns the local transform associated with this node. If no
- local transform has been explicitly set, this method returns a
- QMatrix4x4 set to the identity matrix.
-
- The local transform is typically set during model loading or
- geometry construction, and is a feature of the geometry.
-
- In general to change the location or orientation of the node
- use the position() or transforms() properties instead.
-
- \sa setLocalTransform(), position(), transforms()
-*/
-QMatrix4x4 QGLSceneNode::localTransform() const
-{
- Q_D(const QGLSceneNode);
- return d->localTransform;
-}
-
-/*!
- Sets the local transform associated with this node to be \a transform.
- The default implementation of the QGLSceneNode::draw() method will
- apply this transform to the QGLPainter before drawing any geometry.
-
- \sa localTransform()
-*/
-void QGLSceneNode::setLocalTransform(const QMatrix4x4 &transform)
-{
- Q_D(QGLSceneNode);
- if (d->localTransform != transform)
- {
- d->localTransform = transform;
- emit updated();
- invalidateTransform();
- }
-}
-
-/*!
- \property QGLSceneNode::position
- \brief The amounts of x, y and z axis translation for this node.
-
- Since most nodes are situated relative to \c{(0, 0, 0)} when imported as
- part of a model or constructed programatically, the translation is
- effectively the position of the model in the scene.
-
- The x, y and z axis translations can also be specified individually as
- separate properties \l x, \l y, and \l z
-
- \sa x(), y(), z()
-*/
-QVector3D QGLSceneNode::position() const
-{
- Q_D(const QGLSceneNode);
- return d->translate;
-}
-
-void QGLSceneNode::setPosition(const QVector3D &p)
-{
- Q_D(QGLSceneNode);
- if (p != d->translate)
- {
- d->translate = p;
- emit updated();
- invalidateTransform();
- }
-}
-
-/*!
- \property QGLSceneNode::x
- \brief The amount of x axis translation for this node.
-
- \sa position()
-*/
-qreal QGLSceneNode::x() const
-{
- Q_D(const QGLSceneNode);
- return d->translate.x();
-}
-
-void QGLSceneNode::setX(qreal x)
-{
- Q_D(QGLSceneNode);
- if (x != d->translate.x())
- {
- d->translate.setX(x);
- emit updated();
- invalidateTransform();
- }
-}
-
-/*!
- \property QGLSceneNode::y
- \brief The amount of y axis translation for this node.
-
- \sa position()
-*/
-qreal QGLSceneNode::y() const
-{
- Q_D(const QGLSceneNode);
- return d->translate.y();
-}
-
-void QGLSceneNode::setY(qreal y)
-{
- Q_D(QGLSceneNode);
- if (y != d->translate.y())
- {
- d->translate.setY(y);
- emit updated();
- invalidateTransform();
- }
-}
-
-/*!
- \property QGLSceneNode::z
- \brief The amount of z axis translation for this node.
-
- \sa position()
-*/
-qreal QGLSceneNode::z() const
-{
- Q_D(const QGLSceneNode);
- return d->translate.z();
-}
-
-void QGLSceneNode::setZ(qreal z)
-{
- Q_D(QGLSceneNode);
- if (z != d->translate.z())
- {
- d->translate.setZ(z);
- emit updated();
- invalidateTransform();
- }
-}
-
-/*!
- Returns the list of transformations to apply to this node.
- The default is the empty list.
-
- The transformations are applied to the node itself, so a
- QGraphicsScale3D followed by a QGraphicsTranslation3D will
- first scale the node in its local co-ordinate system,
- and then translate the node a new location.
-
- In the mathematical sense, the transformations are applied to
- the modelview matrix in the reverse order in which they appear
- in this list.
-
- The position() is applied after all other transformations
- have been applied.
-
- \sa setTransforms(), addTransform(), position()
-*/
-QList<QGraphicsTransform3D *> QGLSceneNode::transforms() const
-{
- Q_D(const QGLSceneNode);
- return d->transforms;
-}
-
-/*!
- Sets the list of transformations to apply to this node to \a transforms.
-
- The transformations are applied to the node itself, so a
- QGraphicsScale3D followed by a QGraphicsTranslation3D will
- first scale the node in its local co-ordinate system,
- and then translate the node a new location.
-
- In the mathematical sense, the transformations are applied to
- the modelview matrix in the reverse order in which they appear
- in \a transforms.
-
- The position() is applied after all other transformations
- have been applied.
-
- \sa transforms(), addTransform(), position()
-*/
-void QGLSceneNode::setTransforms(const QList<QGraphicsTransform3D *> &transforms)
-{
- Q_D(QGLSceneNode);
- for (int index = 0; index < d->transforms.size(); ++index) {
- QGraphicsTransform3D *transform = d->transforms.at(index);
- disconnect(transform, SIGNAL(transformChanged()), this, SLOT(transformChanged()));
- }
- d->transforms.clear();
- for (int index = 0; index < transforms.size(); ++index) {
- QGraphicsTransform3D *transform = transforms.at(index);
- if (transform) {
- connect(transform, SIGNAL(transformChanged()), this, SLOT(transformChanged()));
- d->transforms.append(transform);
- }
- }
- emit updated();
- invalidateTransform();
-}
-
-/*!
- Adds a single \a transform to this node, to be applied to the
- node after all current members of transformations() have been applied.
-
- In the mathematical sense, \a transform is applied to the modelview
- matrix before the current members of transformations() are applied
- in reverse order.
-
- \sa transforms(), setTransforms()
-*/
-void QGLSceneNode::addTransform(QGraphicsTransform3D *transform)
-{
- Q_D(QGLSceneNode);
- if (!transform)
- return; // Avoid nulls getting into the transform list.
- connect(transform, SIGNAL(transformChanged()), this, SLOT(transformChanged()));
- d->transforms.append(transform);
- emit updated();
- invalidateTransform();
-}
-
-/*!
- \internal
-*/
-void QGLSceneNode::transformChanged()
-{
- invalidateTransform();
- emit updated();
-}
-
-/*!
- Returns the drawing mode to use to render geometry(). The default
- is QGL::Triangles.
-
- \sa setDrawingMode()
-*/
-QGL::DrawingMode QGLSceneNode::drawingMode() const
-{
- Q_D(const QGLSceneNode);
- return d->drawingMode;
-}
-
-/*!
- Sets the drawing \a mode to use to render geometry().
-
- Note: this function changes the drawing mode, but the underlying
- geometry() still consists of the triangles that were added.
- Thus, this function is only useful for converting the drawing mode
- into QGL::Points to display the geometry() as a point cloud
- instead of a triangle mesh. The other enums from QGL::DrawingMode
- will give unpredictable results.
-
- \sa drawingMode()
-*/
-void QGLSceneNode::setDrawingMode(QGL::DrawingMode mode)
-{
- Q_D(QGLSceneNode);
- if (d->drawingMode != mode)
- {
- d->drawingMode = mode;
- emit updated();
- }
-}
-
-/*!
- Returns the drawing width for this node.
-
- Drawing width is used only when drawing lines or points (ie. when
- the drawing mode is points, lines, line-strips, etc).
-
- \sa drawingMode()
-*/
-qreal QGLSceneNode::drawingWidth() const
-{
- Q_D(const QGLSceneNode);
- return d->drawingWidth;
-}
-
-/*!
- Sets the drawing \a width to the given value.
-
- Drawing width is used only when drawing lines or points (ie. when
- the drawing mode is points, lines, line-strips, etc).
-
- \sa drawingMode()
-*/
-void QGLSceneNode::setDrawingWidth(qreal width)
-{
- Q_D(QGLSceneNode);
- d->drawingWidth = width;
-}
-
-
-/*!
- Returns the local effect associated with this node. The default value
- is QGL::FlatColor. If the value of hasEffect() is false, then this
- the value of effect() is ignored.
-
- \sa setEffect(), hasEffect()
-*/
-QGL::StandardEffect QGLSceneNode::effect() const
-{
- Q_D(const QGLSceneNode);
- return d->localEffect;
-}
-
-/*!
- Sets the local effect associated with this node to be \a effect. hasEffect()
- will return true after calling this method.
-
- The QGLSceneNode::draw() function will ensure that \a effect is applied to the
- QGLPainter before drawing any geometry.
-
- \sa effect(), hasEffect()
-*/
-void QGLSceneNode::setEffect(QGL::StandardEffect effect)
-{
- Q_D(QGLSceneNode);
- if (d->localEffect != effect || !d->hasEffect) {
- d->localEffect = effect;
- d->hasEffect = true;
- emit updated();
- }
-}
-
-/*!
- Returns the user effect associated with this node, or NULL if one is not
- set. The default value is NULL. If the value of hasEffect() is false,
- then this effect is ignored.
-
- \sa setUserEffect(), hasEffect()
-*/
-QGLAbstractEffect *QGLSceneNode::userEffect() const
-{
- Q_D(const QGLSceneNode);
- return d->customEffect;
-}
-
-/*!
- Sets the local effect associated with this node to be the custom
- \a effect. hasEffect() will return true after calling this method.
-
- This custom effect will supersede any standard effect.
-
- The default implementation of QGLSceneNode::apply() will set this effect
- during initialization of the model.
-
- The default implementation of the QGLSceneNode::draw() method will
- ensure that \a effect is applied to the QGLPainter before drawing
- any geometry.
-
- \sa userEffect(), hasEffect()
-*/
-void QGLSceneNode::setUserEffect(QGLAbstractEffect *effect)
-{
- Q_D(QGLSceneNode);
- if (d->customEffect != effect || !d->hasEffect) {
- d->customEffect = effect;
- d->hasEffect = true;
- emit updated();
- }
-}
-
-
- /*!
- Returns true if the local effect on this node is enabled, otherwise
- returns false.
-
- \sa setEffectEnabled(), setEffect()
- */
-bool QGLSceneNode::hasEffect() const
-{
- Q_D(const QGLSceneNode);
- return d->hasEffect;
-}
-
-/*!
- Sets whether the current value of effect() or userEffect() will be
- applied to the QGLPainter prior to drawing. If \a enabled is true,
- then the effect is applied, otherwise it is not.
-
- \sa setEffect(), effect(), hasEffect()
-*/
-void QGLSceneNode::setEffectEnabled(bool enabled)
-{
- Q_D(QGLSceneNode);
- if (d->hasEffect != enabled) {
- d->hasEffect = enabled;
- emit updated();
- }
-}
-
-/*!
- Returns the starting index within geometry() that should be used
- to render fragments for this scene node. The default value is 0,
- indicating that the 0'th logical vertex in geometry() is the start.
-
- \sa setStart(), count()
-*/
-int QGLSceneNode::start() const
-{
- Q_D(const QGLSceneNode);
- return d->start;
-}
-
-/*!
- Sets the \a start index within geometry() that should be used
- to render fragments for this scene node.
-
- \sa start(), setCount()
-*/
-void QGLSceneNode::setStart(int start)
-{
- Q_D(QGLSceneNode);
- if (start != d->start)
- {
- d->start = start;
- emit updated();
- invalidateBoundingBox();
- }
-}
-
-/*!
- Returns the count of the vertices to render from geometry()
- for this scene node. The default is zero, meaning that this node
- uses all vertices from start() up to the last logical vertex
- in the underlying geometry().
-
- \sa setCount(), start()
-*/
-int QGLSceneNode::count() const
-{
- Q_D(const QGLSceneNode);
- return d->count;
-}
-
-/*!
- Sets the \a count of the vertices to render from geometry()
- for this scene node.
-
- \sa count(), setStart()
-*/
-void QGLSceneNode::setCount(int count)
-{
- Q_D(QGLSceneNode);
- if (count != d->count)
- {
- d->count = count;
- emit updated();
- invalidateBoundingBox();
- }
-}
-
-/*!
- Returns the material index for this scene node.
-
- \sa setMaterialIndex()
-*/
-int QGLSceneNode::materialIndex() const
-{
- Q_D(const QGLSceneNode);
- return d->material;
-}
-
-/*!
- Sets the material index for this scene node to \a material.
-
- \sa materialIndex()
-*/
-void QGLSceneNode::setMaterialIndex(int material)
-{
- Q_D(QGLSceneNode);
- if (d->material != material) {
- d->material = material;
- emit updated();
- }
-}
-
-/*!
- Returns the back material index for this scene node.
-
- \sa setBackMaterialIndex()
-*/
-int QGLSceneNode::backMaterialIndex() const
-{
- Q_D(const QGLSceneNode);
- return d->backMaterial;
-}
-
-/*!
- Sets the back material index for this scene node to \a material.
-
- \sa materialIndex()
-*/
-void QGLSceneNode::setBackMaterialIndex(int material)
-{
- Q_D(QGLSceneNode);
- if (d->backMaterial != material) {
- d->backMaterial = material;
- emit updated();
- }
-}
-
-/*!
- \property QGLSceneNode::material
- \brief This property is a pointer to a QGLMaterial instance for this node.
-
- This material is applied to all faces if the backMaterial() property
- is set to null, which is the default. If the backMaterial() property is non-null
- then this material is only applied to the front faces.
-
- To apply a material to the back faces use the backMaterial() property.
-
- Getting this property is exactly equivalent to
- \c{palette()->material(materialIndex())}.
-
- Setting this property causes the material if not already in this nodes palette to be
- added, and then the corresponding index to be set for this scene node.
-
- Setting this property is equivalent to:
- \code
- int index = d->palette->indexOf(material);
- if (index == -1)
- index = d->palette->addMaterial(material);
- setMaterialIndex(index);
- \endcode
-
- If setting this property, when no palette exists one is created, as a
- convenience - but this is suitable only for experimental code and for
- \bold{very small numbers of nodes}. In debug mode a warning is
- printed in this case.
-
- Generally one common palette should be created, and set on each node. This
- also allows nodes to share materials and their textures.
-
- \sa materialIndex(), setMaterialIndex()
-*/
-QGLMaterial *QGLSceneNode::material() const
-{
- Q_D(const QGLSceneNode);
- if (d->palette)
- return d->palette->material(d->material);
- return 0;
-}
-
-void QGLSceneNode::setMaterial(QGLMaterial *material)
-{
- Q_D(QGLSceneNode);
- if (!d->palette)
- d->palette = new QGLMaterialCollection(this);
- int ix = d->palette->indexOf(material);
- if (ix == -1)
- ix = d->palette->addMaterial(material);
- setMaterialIndex(ix);
-}
-
-/*!
- \property QGLSceneNode::backMaterial
- \brief This property is a pointer to any QGLMaterial instance for this node's back faces.
-
- This material is applied to the back faces, if non-null. The default value
- of this property is null. When this property is null, any non-null material
- set on the material() property will be applied to front and back faces.
-
- To apply a material to the front faces use the material() property.
-
- Getting this property is exactly equivalent to
- \c{palette()->material(backMaterialIndex())}.
-
- Setting this property causes the material if not already in this nodes palette to be
- added, and then the corresponding index to be set for this scene node.
-
- Setting this property is exactly equivalent to:
- \code
- int index = d->palette->indexOf(material);
- if (index == -1)
- index = d->palette->addMaterial(material);
- setBackMaterialIndex(index);
- \endcode
-*/
-QGLMaterial *QGLSceneNode::backMaterial() const
-{
- Q_D(const QGLSceneNode);
- if (d->palette)
- return d->palette->material(d->backMaterial);
- return 0;
-}
-
-void QGLSceneNode::setBackMaterial(QGLMaterial *material)
-{
- Q_D(QGLSceneNode);
- if (!d->palette)
- d->palette = new QGLMaterialCollection(this);
- int ix = d->palette->indexOf(material);
- if (ix == -1)
- ix = d->palette->addMaterial(material);
- setBackMaterialIndex(ix);
-}
-/*!
- Returns the palette of materials used by this scene node, or NULL
- if no palette has been set.
-
- \sa setPalette()
-*/
-QGLMaterialCollection *QGLSceneNode::palette() const
-{
- Q_D(const QGLSceneNode);
- return d->palette;
-}
-
-/*!
- Sets the palette of materials for this scene node to \a palette.
-
- \sa palette()
-*/
-void QGLSceneNode::setPalette(QGLMaterialCollection *palette)
-{
- Q_D(QGLSceneNode);
- if (d->palette != palette) {
- d->palette = palette;
- emit updated();
- }
-}
-
-/*!
- Returns a list of the child nodes for this node. This list is not
- recursively generated, it includes only the nodes which are
- immediate children of this node.
-
- \sa allChildren()
-*/
-QList<QGLSceneNode*> QGLSceneNode::children() const
-{
- Q_D(const QGLSceneNode);
- return d->childNodes;
-}
-
-/*!
- Returns a list including recursively all child nodes under
- this node. Each child node only appears once, even if it is included
- multiple times in the scene graph.
-
- \sa children()
-*/
-QList<QGLSceneNode*> QGLSceneNode::allChildren() const
-{
- Q_D(const QGLSceneNode);
- QList<QGLSceneNode*> allSceneNodes;
- QList<QGLSceneNode*> gather;
- QList<QGLSceneNode*>::const_iterator it = d->childNodes.constBegin();
- for ( ; it != d->childNodes.constEnd(); ++it)
- if (!gather.contains(*it))
- gather.append(*it);
- while (gather.count() > 0)
- {
- QGLSceneNode *node = gather.takeFirst();
- if (!allSceneNodes.contains(node))
- {
- allSceneNodes.append(node);
- gather.append(node->children());
- }
- }
- return allSceneNodes;
-}
-
-/*!
- Adds the \a node to the list of child nodes for this node.
-
- This function does nothing if \a node is null or is already a child
- of this node. If the \a node is the node itself, a warning about an
- attempt to add a node to itself is printed, and no add takes place.
-
- If the aim is to have the same geometry displayed several times under a
- given node, each time with different transformations, use the clone()
- call to create copies of the node and then apply the transformations to
- the copies.
-
- Alternatively, create modifier nodes with the transformations and add the
- geometry bearing node to each with addNode():
- \code
- QGLBuilder builder;
- builder << CarWheel(5.0f); // some car wheel geometry
- QGLSceneNode wheel = builder.finalizedSceneNode();
- QGLSceneNode frontLeft = new QGLSceneNode(m_sceneRoot);
- frontLeft->addNode(wheel);
- frontLeft->setPosition(QVector3D(1.0f, 2.0f, 0.0f));
- QGLSceneNode frontRight = new QGLSceneNode(m_sceneRoot);
- frontRight->addNode(wheel);
- frontRight->setPosition(QVector3D(-1.0f, 2.0f, 0.0f));
- QGLSceneNode backLeft = new QGLSceneNode(m_sceneRoot);
- backLeft->addNode(wheel);
- backLeft->setPosition(QVector3D(1.0f, -2.0f, 0.0f));
- QGLSceneNode backRight = new QGLSceneNode(m_sceneRoot);
- backRight->addNode(wheel);
- backRight->setPosition(QVector3D(-1.0f, -2.0f, 0.0f));
- \endcode
-
- Because a child node can be validly added to many different nodes,
- calling addNode() does not normally affect the QObject::parent()
- ownership. However, if \a node does not currently have a
- QObject::parent(), the parent will be set to this node.
-
- \sa removeNode(), clone(), addNodes()
-*/
-void QGLSceneNode::addNode(QGLSceneNode *node)
-{
- Q_D(QGLSceneNode);
- bool alreadyAdded = node && node->d_ptr->parentNodes.contains(this);
- if (!node || node == this || alreadyAdded)
- return; // Invalid node, or already under this parent.
- invalidateBoundingBox();
- d->childNodes.append(node);
- node->d_ptr->parentNodes.append(this);
- if (!node->parent())
- node->setParent(this);
- connect(node, SIGNAL(updated()), this, SIGNAL(updated()));
- emit updated();
-}
-
-/*!
- Adds the members of \a nodes to the list of child nodes
- for this node.
-
- \sa addNode(), removeNodes()
-*/
-void QGLSceneNode::addNodes(const QList<QGLSceneNode *> &nodes)
-{
- Q_D(QGLSceneNode);
- for (int index = 0; index < nodes.count(); ++index) {
- QGLSceneNode *node = nodes.at(index);
- if (!node || node->d_ptr->parentNodes.contains(this))
- continue; // Invalid node, or already under this parent.
- d->childNodes.append(node);
- node->d_ptr->parentNodes.append(this);
- if (!node->parent())
- node->setParent(this);
- connect(node, SIGNAL(updated()), this, SIGNAL(updated()));
- }
- invalidateBoundingBox();
- emit updated();
-}
-
-/*!
- Removes the child node matching \a node from this node.
-
- If the QObject::parent() ownership of \a node was set to this
- node, then its parent will be changed to another parent node if it
- had multiple parents.
-
- If \a node had only a single parent, then its parent will be set to null,
- effectively detaching it from the QObject ownership rules of the scene
- graph. The caller is then responsible for deleting \a node.
-
- If the QObject::parent() of \a node was not a scene node parent,
- then it will be left unmodified.
-
- \sa addNode(), removeNodes()
-*/
-void QGLSceneNode::removeNode(QGLSceneNode *node)
-{
- Q_D(QGLSceneNode);
- if (!node || !node->d_ptr->parentNodes.contains(this))
- return; // Invalid node or not attached to this parent.
- d->childNodes.removeOne(node);
- node->d_ptr->parentNodes.removeOne(this);
- if (node->parent() == this) {
- // Transfer QObject ownership to another parent, or null.
- if (!node->d_ptr->parentNodes.isEmpty())
- node->setParent(node->d_ptr->parentNodes[0]);
- else
- node->setParent(0);
- }
- disconnect(node, SIGNAL(updated()), this, SIGNAL(updated()));
- invalidateBoundingBox();
- emit updated();
-}
-
-/*!
- Removes the members of \a nodes from the list of child nodes
- for this node.
-
- \sa removeNode(), addNodes()
-*/
-void QGLSceneNode::removeNodes(const QList<QGLSceneNode *> &nodes)
-{
- Q_D(QGLSceneNode);
- for (int index = 0; index < nodes.count(); ++index) {
- QGLSceneNode *node = nodes.at(index);
- if (!node || !node->d_ptr->parentNodes.contains(this))
- continue; // Invalid node or not attached to this parent.
- d->childNodes.removeOne(node);
- node->d_ptr->parentNodes.removeOne(this);
- if (node->parent() == this) {
- // Transfer QObject ownership to another parent, or null.
- if (!node->d_ptr->parentNodes.isEmpty())
- node->setParent(node->d_ptr->parentNodes[0]);
- else
- node->setParent(0);
- }
- disconnect(node, SIGNAL(updated()), this, SIGNAL(updated()));
- }
- invalidateBoundingBox();
- emit updated();
-}
-
-void QGLSceneNode::invalidateBoundingBox() const
-{
- Q_D(const QGLSceneNode);
- d->boxValid = false;
- d->invalidateParentBoundingBox();
-}
-
-void QGLSceneNode::invalidateTransform() const
-{
- invalidateBoundingBox();
-}
-
-void QGLSceneNode::drawNormalIndicators(QGLPainter *painter)
-{
- Q_D(QGLSceneNode);
- QVector3DArray verts;
- QGL::IndexArray indices = d->geometry.indices();
- for (int i = d->start; i < (d->start + d->count); ++i)
- {
- int ix = indices[i];
- QVector3D a = d->geometry.vertexAt(ix);
- QVector3D b = a + d->geometry.normalAt(ix);
- verts.append(a, b);
- }
- painter->setVertexAttribute(QGL::Position, QGLAttributeValue(verts));
- glLineWidth(2.0f);
- painter->draw(QGL::Lines, verts.size());
-}
-
-const QGLMaterial *QGLSceneNode::setPainterMaterial(int material, QGLPainter *painter,
- QGL::Face faces, bool &changedTex)
-{
- Q_D(QGLSceneNode);
- QGLMaterial *mat = d->palette->material(material);
- const QGLMaterial *saveMat = 0;
- if (painter->faceMaterial(faces) != mat)
- {
- saveMat = painter->faceMaterial(faces);
- painter->setFaceMaterial(faces, mat);
- int texUnit = 0;
- for (int i = 0; i < mat->textureLayerCount(); ++i)
- {
- QGLTexture2D *tex = mat->texture(i);
- if (tex)
- {
- painter->glActiveTexture(GL_TEXTURE0 + texUnit);
- tex->bind();
- changedTex = true;
- ++texUnit;
- }
- }
- }
- return saveMat;
-}
-
-/*!
- Draws the geometry of the node onto the \a painter.
-
- This is the function which performs the actual drawing step in the
- draw function below.
-
- \list
- \o calls draw(start, count) on this nodes geometry object (if any)
- \endlist
-
- Override this function to perform special processing on this node,
- after transformation & culling are applied and before sequencing of
- materials & effects are done; but just before (or after) the
- actual draw step.
-
- This default implementation simply draws the nodes geometry onto
- the painter.
-
- Example:
- \code
- void MySpecialNode::geometryDraw(QGLPainter *painter)
- {
- // at this point the node has survived culling, the model-view
- // matrix is transformed into this nodes frame of reference,
- // materials & effects have been applied as this node appears
- // in its place in the render sequence
-
- doMySpecialProcessing();
-
- // call parent implementation to do actual draw
- QGLSceneNode::geometryDraw(painter);
- }
- \endcode
-*/
-void QGLSceneNode::drawGeometry(QGLPainter *painter)
-{
- Q_D(QGLSceneNode);
- if (d->count && d->geometry.count() > 0)
- d->geometry.draw(painter, d->start, d->count, d->drawingMode, d->drawingWidth);
-}
-
-/*!
- Draws this scene node and its children on the \a painter.
-
- In detail this function:
- \list
- \o ensures the effect specified by effect() is current on the painter
- \o sets the nodes materials onto the painter, if valid materials are present
- \o moves the model-view to the x, y, z position
- \o applies any local transforms() that may be set for this node
- \o calls draw() for all the child nodes
- \o calls draw(start, count) on this nodes geometry object (if any)
- \o restores the geometry's original materials if they were changed
- \o restores the model-view matrix if any local transform was applied
- \endlist
-
- Note that the draw() method does \bold not restore the effect. If the first
- step above results in a change to the current QGL::Standard effect then it
- will remain set to that effect. In general any painting method should
- ensure the effect it requires is current.
-
- The way draw is implemented ensures that this nodes effects, materials and
- transformations will apply by default to its child nodes. Transformations
- are cumulative, but effects and materials override those of any parent node.
-
- Note that if the HideNode option is set for this node, neither it nor its
- children will be drawn.
-*/
-void QGLSceneNode::draw(QGLPainter *painter)
-{
- Q_D(QGLSceneNode);
- if (d->options & HideNode)
- return;
- bool wasTransformed = false;
-
- QGLRenderSequencer *seq = painter->renderSequencer();
-
- if (seq->top() != this)
- {
- QMatrix4x4 m = transform();
-
- if (!m.isIdentity())
- {
- painter->modelViewMatrix().push();
- painter->modelViewMatrix() *= m;
- wasTransformed = true;
- }
-
- if (d->options & CullBoundingBox)
- {
- QBox3D bb = boundingBox();
- if (bb.isFinite() && !bb.isNull() && painter->isCullable(bb))
- {
- if (!d->culled && d->options & ReportCulling)
- {
- d->culled = true;
- emit culled();
- }
- if (wasTransformed)
- painter->modelViewMatrix().pop();
- return;
- }
- else
- {
- if (d->culled && d->options & ReportCulling)
- {
- d->culled = false;
- emit displayed();
- }
- }
- }
- }
-
- if (seq->top() == NULL)
- {
- seq->setTop(this);
- while (true)
- {
- draw(painter); // recursively draw myself for each state
- if (!seq->nextInSequence())
- break;
- }
- seq->reset();
- }
- else
- {
- bool stateEntered = false;
- if (d->childNodes.size() > 0)
- {
- seq->beginState(this);
- stateEntered = true;
- QList<QGLSceneNode*>::iterator cit = d->childNodes.begin();
- for ( ; cit != d->childNodes.end(); ++cit)
- (*cit)->draw(painter);
- }
-
- if (d->count && (d->geometry.count() > 0) && seq->renderInSequence(this))
- {
- bool idSaved = false;
- int id = -1;
- if (d->pickNode && painter->isPicking())
- {
- idSaved = true;
- id = painter->objectPickId();
- painter->setObjectPickId(d->pickNode->id());
- }
-
- if (!stateEntered)
- {
- stateEntered = true;
- seq->beginState(this);
- }
- seq->applyState();
-
- drawGeometry(painter);
-
- if (idSaved)
- painter->setObjectPickId(id);
-
- if (d->options & ViewNormals)
- drawNormalIndicators(painter);
- }
- if (stateEntered)
- seq->endState(this);
- }
- if (wasTransformed)
- painter->modelViewMatrix().pop();
-}
-
-/*!
- Returns the pick node for this scene node, if one was set; otherwise
- NULL (0) is returned.
-
- \sa setPickNode()
-*/
-QGLPickNode *QGLSceneNode::pickNode() const
-{
- Q_D(const QGLSceneNode);
- return d->pickNode;
-}
-
-/*!
- Sets the pick node for this scene node to \a node.
-
- \sa pickNode()
-*/
-void QGLSceneNode::setPickNode(QGLPickNode *node)
-{
- Q_D(QGLSceneNode);
- // TODO - resolve recursive picking - not supported by
- // color based pick AFAICT
- d->pickNode = node;
- if (node)
- node->setTarget(this);
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry, child nodes, and
- have all effects, transforms and other properties copied from this node.
- The only property that is not copied is pickNode().
-
- \sa cloneNoChildren()
-*/
-QGLSceneNode *QGLSceneNode::clone(QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = new QGLSceneNode
- (new QGLSceneNodePrivate(d), parent ? parent : this->parent());
- for (int index = 0; index < d->transforms.size(); ++index)
- node->addTransform(d->transforms.at(index)->clone(node));
- node->addNodes(d->childNodes);
- return node;
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry, and
- have all effects, transforms and other properties copied from this node.
- The children() and pickNodes() are not cloned.
-
- \sa clone()
-*/
-QGLSceneNode *QGLSceneNode::cloneNoChildren(QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = new QGLSceneNode
- (new QGLSceneNodePrivate(d), parent ? parent : this->parent());
- for (int index = 0; index < d->transforms.size(); ++index)
- node->addTransform(d->transforms.at(index)->clone(node));
- return node;
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry and
- have all effects, transforms and other properties copied from this node.
-
- The copy returned will have the same child nodes, except all child nodes
- whose objectName() is equal to \a name.
-
- \sa clone(), only()
-*/
-QGLSceneNode *QGLSceneNode::allExcept(const QString &name, QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = cloneNoChildren(parent);
- for (int index = 0; index < d->childNodes.count(); ++index) {
- QGLSceneNode *child = d->childNodes.at(index);
- if (child->objectName() != name)
- node->addNode(child);
- }
- return node;
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry and
- have all effects, transforms and other properties copied from this node.
-
- The copy returned will have only one child node. This child node will be
- the first child node of this one which has its objectName() equal to \a name.
-
- \sa clone(), allExcept()
-*/
-QGLSceneNode *QGLSceneNode::only(const QString &name, QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = cloneNoChildren(parent);
- for (int index = 0; index < d->childNodes.count(); ++index) {
- QGLSceneNode *child = d->childNodes.at(index);
- if (child->objectName() == name) {
- node->addNode(child);
- break;
- }
- }
- return node;
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry and
- have all effects, transforms and other properties copied from this node.
-
- The copy returned will have the same child nodes, except all child nodes
- whose objectName() is in the list of \a names.
-
- \sa clone(), only()
-*/
-QGLSceneNode *QGLSceneNode::allExcept(const QStringList &names, QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = cloneNoChildren(parent);
- QSet<QString> chk = QSet<QString>::fromList(names);
- for (int index = 0; index < d->childNodes.count(); ++index) {
- QGLSceneNode *child = d->childNodes.at(index);
- if (!chk.contains(child->objectName()))
- node->addNode(child);
- }
- return node;
-}
-
-/*!
- Creates a new QGLSceneNode that is a copy of this scene node, with
- \a parent as the parent of the new copy. If parent is NULL then parent
- is set to this nodes parent.
-
- The copy will reference the same underlying geometry and
- have all effects, transforms and other properties copied from this node.
-
- The copy returned will have only the child nodes from this
- whose objectName() is in the list of \a names.
-
- \sa clone(), allExcept()
-*/
-QGLSceneNode *QGLSceneNode::only(const QStringList &names, QObject *parent) const
-{
- Q_D(const QGLSceneNode);
- QGLSceneNode *node = cloneNoChildren(parent);
- QSet<QString> chk = QSet<QString>::fromList(names);
- for (int index = 0; index < d->childNodes.count(); ++index) {
- QGLSceneNode *child = d->childNodes.at(index);
- if (chk.contains(child->objectName()))
- node->addNode(child);
- }
- return node;
-}
-
-/*!
- \fn QGLSceneNode::updated()
- Signals that some property of this scene node, or one of its children,
- has changed in a manner that will require that the node be redrawn.
-*/
-
-/*!
- \fn QGLSceneNode::culled()
- Signals that the node was culled due to falling wholly outside the view
- frustum. This signal can only fire if both QGLSceneNode::CullBoundingBox
- and QGLSceneNode::ReportCulling options are both set.
-*/
-
-/*!
- \fn QGLSceneNode::displayed()
- Signals that the node was displayed - or at least its geometry was sent
- to the GPU for rendering, since the GPU might still clip or occlude the
- node. This signal can only fire if both QGLSceneNode::CullBoundingBox
- and QGLSceneNode::ReportCulling options are both set.
-*/
-
-/*!
- \relates QGLSceneNode
- Print a description of \a node, and all its descendants, to the console.
- This function uses qDebug for its output, so in the case of Windows the
- output will go to the debug window. If QT_NO_DEBUG_OUTPUT or QT_NO_DEBUG
- has been defined, (as in release mode) this function will exit without
- doing anything.
-
- If \a detailed is true (which it is by default) then all the properties
- of each node are printed, including materials, geometry and transforms.
-
- If \a detailed is false, then just one line is printed with the name and
- some identifying information including a unique id for the node.
-
- The \a indent and \a loop parameters are used internally.
-*/
-void qDumpScene(QGLSceneNode *node, bool detailed, int indent, const QSet<QGLSceneNode *> &loop)
-{
-#if defined(QT_NO_DEBUG_STREAM) || defined(QT_NO_DEBUG) || defined(QT_NO_DEBUG_OUTPUT)
- Q_UNUSED(node);
- Q_UNUSED(detailed);
- Q_UNUSED(indent);
- Q_UNUSED(loop);
-#else
-#if !defined(QT_NO_THREAD)
- QCoreApplication *app = QApplication::instance();
- QThread *appThread = 0;
- if (app)
- appThread = QApplication::instance()->thread();
-#endif
- QSet<QGLSceneNode *> lp = loop;
- lp.insert(node);
- QString ind;
- ind.fill(QLatin1Char(' '), indent * 4);
- if (detailed)
- {
- qDebug("\n%s ======== Node: %p - %s =========", qPrintable(ind), node,
- qPrintable(node->objectName()));
- }
- else
- {
- qDebug("\n%s Node: %p - %s", qPrintable(ind), node,
- qPrintable(node->objectName()));
- return;
- }
-#if !defined(QT_NO_THREAD)
- if (appThread && appThread != node->thread())
- qDebug("\n%s from thread: %p", qPrintable(ind), node->thread());
-#endif
- qDebug("%s start: %d count: %d children:", qPrintable(ind), node->start(), node->count());
- {
- QList<QGLSceneNode*> children = node->children();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for (int i = 0; it != children.constEnd(); ++it, ++i)
- qDebug("%s %d: %p ", qPrintable(ind), i, *it);
- }
- if (!node->position().isNull())
- {
- QVector3D p = node->position();
- qDebug("%s position: (%0.4f, %0.4f, %0.4f)", qPrintable(ind),
- p.x(), p.y(), p.z());
- }
- if (node->localTransform().isIdentity())
- {
- qDebug("%s local transform: identity", qPrintable(ind));
- }
- else
- {
- qDebug("%s local transform:", qPrintable(ind));
- QMatrix4x4 m = node->localTransform();
- for (int i = 0; i < 4; ++i)
- qDebug("%s %0.4f %0.4f %0.4f %0.4f",
- qPrintable(ind), m(i, 0), m(i, 1), m(i, 2), m(i, 3));
- }
- QList<QGraphicsTransform3D*> tx = node->transforms();
- if (tx.size() > 0)
- qDebug("%s transforms list:", qPrintable(ind));
- for (int i = 0; i < tx.size(); ++i)
- {
- const QMetaObject *obj = tx.at(i)->metaObject();
- qDebug("%s %s", qPrintable(ind), obj->className());
- }
- if (!node->geometry().isEmpty())
- {
- qDebug("%s geometry: %d indexes, %d vertices",
- qPrintable(ind), node->geometry().count(), node->geometry().count(QGL::Position));
- }
- else
- {
- qDebug("%s geometry: NULL", qPrintable(ind));
- }
- if (node->materialIndex() != -1)
- {
- qDebug("%s material: %d", qPrintable(ind), node->materialIndex());
- QGLMaterial *mat = node->material();
- QGLMaterialCollection *pal = node->palette();
- if (pal)
- qDebug("%s palette: %p", qPrintable(ind), pal);
- else
- qDebug("%s no palette", qPrintable(ind));
- if (pal)
- {
- mat = pal->material(node->materialIndex());
- if (mat)
- qDebug("%s mat name from pal: %s ", qPrintable(ind),
- qPrintable(pal->material(node->materialIndex())->objectName()));
- else
- qDebug("%s indexed material %d does not exist in palette!",
- qPrintable(ind), node->materialIndex());
- }
- if (mat)
- {
- QString mat_spx = QString(QLatin1String(" Amb: %1 - Diff: %2 - Spec: %3 - Shin: %4"))
- .arg((mat->ambientColor().name()))
- .arg(mat->diffuseColor().name())
- .arg(mat->specularColor().name())
- .arg(mat->shininess());
- if (mat->objectName().isEmpty())
- qDebug("%s material pointer %p: %s", qPrintable(ind), mat, qPrintable(mat_spx));
- else
- qDebug("%s \"%s\": %s", qPrintable(ind),
- qPrintable(mat->objectName()), qPrintable(mat_spx));
- for (int i = 0; i < mat->textureLayerCount(); ++i)
- {
- if (mat->texture(i) != 0)
- {
- QGLTexture2D *tex = mat->texture(i);
- if (tex->objectName().isEmpty())
- qDebug("%s texture %p", qPrintable(ind), tex);
- else
- qDebug("%s texture %s", qPrintable(ind),
- qPrintable(tex->objectName()));
- QSize sz = tex->size();
- qDebug(" - size: %d (w) x %d (h)", sz.width(), sz.height());
- }
- }
- }
- else
- {
- qDebug("%s - could not find indexed material!!", qPrintable(ind));
- }
- }
- else
- {
- qDebug("%s material: NONE", qPrintable(ind));
- }
-
- if (node->hasEffect())
- {
- if (node->userEffect())
- {
- qDebug("%s user effect %p", qPrintable(ind),
- node->userEffect());
- }
- else
- {
- switch (node->effect())
- {
- case QGL::FlatColor:
- qDebug("%s flat color effect", qPrintable(ind)); break;
- case QGL::FlatPerVertexColor:
- qDebug("%s flat per vertex color effect", qPrintable(ind)); break;
- case QGL::FlatReplaceTexture2D:
- qDebug("%s flat replace texture 2D effect", qPrintable(ind)); break;
- case QGL::FlatDecalTexture2D:
- qDebug("%s flat decal texture 2D effect", qPrintable(ind)); break;
- case QGL::LitMaterial:
- qDebug("%s lit material effect", qPrintable(ind)); break;
- case QGL::LitDecalTexture2D:
- qDebug("%s lit decal texture 2D effect", qPrintable(ind)); break;
- case QGL::LitModulateTexture2D:
- qDebug("%s lit modulate texture 2D effect", qPrintable(ind)); break;
- }
- }
- }
- else
- {
- qDebug("%s no effect set", qPrintable(ind));
- }
- QList<QGLSceneNode*> children = node->children();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for ( ; it != children.constEnd(); ++it)
- if (!lp.contains(*it))
- qDumpScene(*it, indent + 1);
-#endif
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QGLSceneNode &node)
-{
- dbg << &node << "\n start:" << node.start() << " count:" << node.count();
- QList<QGLSceneNode*> children = node.children();
- QList<QGLSceneNode*>::const_iterator it = children.constBegin();
- for ( ; it != children.constEnd(); ++it)
- dbg << "\n child:" << *it;
-
- if (node.localTransform().isIdentity())
- dbg << "\n local transform: identity";
- else
- dbg << "\n local transform:\n" << node.localTransform();
-
- if (node.geometry().count() > 0)
- {
- QGLMaterial *mat = node.material();
- QString mdesc;
- if (mat)
- mdesc = mat->objectName();
- dbg << "\n geometry:" << node.geometry();
- dbg << "\n material" << node.material() << ": " << mat << mdesc;
- }
- else
- {
- dbg << "\n geometry: NULL";
- dbg << "\n material" << node.material();
- }
-
- if (node.hasEffect())
- {
- if (node.userEffect())
- {
- dbg << "\n user effect";
- }
- else
- {
- switch (node.effect())
- {
- case QGL::FlatColor:
- dbg << "\n flat color effect"; break;
- case QGL::FlatPerVertexColor:
- dbg << "\n flat per vertex color effect"; break;
- case QGL::FlatReplaceTexture2D:
- dbg << "\n flat replace texture 2D effect"; break;
- case QGL::FlatDecalTexture2D:
- dbg << "\n flat decal texture 2D effect"; break;
- case QGL::LitMaterial:
- dbg << "\n lit material effect"; break;
- case QGL::LitDecalTexture2D:
- dbg << "\n lit decal texture 2D effect"; break;
- case QGL::LitModulateTexture2D:
- dbg << "\n lit modulate texture 2D effect"; break;
- }
- }
- }
- else
- {
- dbg << "\n no effect set";
- }
- return dbg;
-}
-
-#endif // QT_NO_DEBUG_STREAM
-
-QT_END_NAMESPACE
diff --git a/src/threed/scene/qglscenenode.h b/src/threed/scene/qglscenenode.h
deleted file mode 100644
index edf08874..00000000
--- a/src/threed/scene/qglscenenode.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSCENENODE_H
-#define QGLSCENENODE_H
-
-#include <QtCore/qobject.h>
-
-#include "qgeometrydata.h"
-#include "qglmaterialcollection.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSceneNodePrivate;
-class QGLAbstractEffect;
-class QGLPickNode;
-class QGraphicsTransform3D;
-
-class Q_QT3D_EXPORT QGLSceneNode : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGLSceneNode)
- Q_ENUMS(Option)
- Q_FLAGS(Options)
- Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY updated)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY updated)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY updated)
- Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY updated)
- Q_PROPERTY(QGLMaterial *material READ material WRITE setMaterial NOTIFY updated)
- Q_PROPERTY(QGLMaterial *backMaterial READ backMaterial WRITE setBackMaterial NOTIFY updated)
- Q_PROPERTY(Options options READ options WRITE setOptions NOTIFY updated)
-public:
- explicit QGLSceneNode(QObject *parent = 0);
- explicit QGLSceneNode(const QGeometryData &geometry, QObject *parent = 0);
- virtual ~QGLSceneNode();
-
- enum Option
- {
- NoOptions = 0x0000,
- CullBoundingBox = 0x0001,
- ViewNormals = 0x0002,
- ReportCulling = 0x0004,
- HideNode = 0x0008
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QGLSceneNode::Options options() const;
- void setOptions(QGLSceneNode::Options options);
- void setOption(QGLSceneNode::Option option, bool value);
-
- QGeometryData geometry() const;
- void setGeometry(QGeometryData);
-
- QBox3D boundingBox() const;
-
- QMatrix4x4 localTransform() const;
- void setLocalTransform(const QMatrix4x4 &);
- QVector3D position() const;
- void setPosition(const QVector3D &p);
- qreal x() const;
- void setX(qreal x);
- qreal y() const;
- void setY(qreal y);
- qreal z() const;
- void setZ(qreal z);
-
- QList<QGraphicsTransform3D *> transforms() const;
- void setTransforms(const QList<QGraphicsTransform3D *> &transforms);
- void addTransform(QGraphicsTransform3D *transform);
-
- QGL::DrawingMode drawingMode() const;
- void setDrawingMode(QGL::DrawingMode mode);
-
- qreal drawingWidth() const;
- void setDrawingWidth(qreal width);
-
- QGL::StandardEffect effect() const;
- void setEffect(QGL::StandardEffect);
-
- QGLAbstractEffect *userEffect() const;
- void setUserEffect(QGLAbstractEffect *effect);
-
- bool hasEffect() const;
- void setEffectEnabled(bool);
-
- int start() const;
- void setStart(int start);
-
- int count() const;
- void setCount(int count);
-
- int materialIndex() const;
- void setMaterialIndex(int material);
- int backMaterialIndex() const;
- void setBackMaterialIndex(int material);
-
- QGLMaterial *material() const;
- void setMaterial(QGLMaterial *material);
- QGLMaterial *backMaterial() const;
- void setBackMaterial(QGLMaterial *material);
-
- QGLMaterialCollection *palette() const;
- void setPalette(QGLMaterialCollection *palette);
-
- QList<QGLSceneNode*> allChildren() const;
- QList<QGLSceneNode *> children() const;
-
- void addNode(QGLSceneNode *node);
- void addNodes(const QList<QGLSceneNode *> &nodes);
- void removeNode(QGLSceneNode *node);
- void removeNodes(const QList<QGLSceneNode *> &nodes);
-
- virtual void draw(QGLPainter *painter);
-
- QGLPickNode *pickNode() const;
- void setPickNode(QGLPickNode *node);
-
- Q_INVOKABLE QGLSceneNode *clone(QObject *parent = 0) const;
- Q_INVOKABLE QGLSceneNode *cloneNoChildren(QObject *parent = 0) const;
- Q_INVOKABLE QGLSceneNode *allExcept(const QString &name, QObject *parent = 0) const;
- Q_INVOKABLE QGLSceneNode *only(const QString &name, QObject *parent = 0) const;
- Q_INVOKABLE QGLSceneNode *allExcept(const QStringList &names, QObject *parent = 0) const;
- Q_INVOKABLE QGLSceneNode *only(const QStringList &names, QObject *parent = 0) const;
-
-Q_SIGNALS:
- void updated();
- void culled();
- void displayed();
-
-protected:
- virtual void drawGeometry(QGLPainter *painter);
-
-private Q_SLOTS:
- void transformChanged();
-
-private:
- QMatrix4x4 transform() const;
- void invalidateBoundingBox() const;
- void invalidateTransform() const;
- void drawNormalIndicators(QGLPainter *painter);
- const QGLMaterial *setPainterMaterial(int material, QGLPainter *painter,
- QGL::Face faces, bool &changedTex);
-
- Q_DISABLE_COPY(QGLSceneNode)
-
- QScopedPointer<QGLSceneNodePrivate> d_ptr;
-
- QGLSceneNode(QGLSceneNodePrivate *d, QObject *parent);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLSceneNode::Options)
-
-Q_QT3D_EXPORT void qDumpScene(QGLSceneNode *, bool detailed = true, int indent = 0, const QSet<QGLSceneNode*> &loop = QSet<QGLSceneNode*>());
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLSceneNode &node);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/scene/qglscenenode_p.h b/src/threed/scene/qglscenenode_p.h
deleted file mode 100644
index 21028ddb..00000000
--- a/src/threed/scene/qglscenenode_p.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSCENENODE_P_H
-#define QGLSCENENODE_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.
-//
-
-#include "qglnamespace.h"
-#include "qglscenenode.h"
-#include "qgraphicstransform3d.h"
-
-#include <QtGui/qmatrix4x4.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qset.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLAbstractEffect;
-class QGLPickNode;
-
-class QGLSceneNodePrivate
-{
-public:
- QGLSceneNodePrivate()
- : palette(0)
- , localEffect(QGL::FlatColor) // 0 - zero
- , customEffect(0)
- , hasEffect(false)
- , material(-1)
- , backMaterial(-1)
- , start(0)
- , count(0)
- , options(0)
- , pickNode(0)
- , boxValid(false)
- , drawingMode(QGL::Triangles)
- , culled(false)
- {
- }
-
- // This constructor is used by QGLSceneNode::clone().
- QGLSceneNodePrivate(const QGLSceneNodePrivate *other)
- : geometry(other->geometry)
- , palette(other->palette)
- , localTransform(other->localTransform)
- , translate(other->translate)
- , localEffect(other->localEffect)
- , customEffect(other->customEffect)
- , hasEffect(other->hasEffect)
- , material(other->material)
- , backMaterial(other->backMaterial)
- , start(other->start)
- , count(other->count)
- , options(other->options)
- , pickNode(0) // Explicitly not cloned.
- , bb(other->bb)
- , boxValid(other->boxValid)
- , drawingMode(other->drawingMode)
- , drawingWidth(1.0)
- , culled(other->culled)
- {
- }
-
- inline void invalidateParentBoundingBox() const
- {
- QList<QGLSceneNode*>::const_iterator it = parentNodes.constBegin();
- for ( ; it != parentNodes.constEnd(); ++it)
- (*it)->invalidateBoundingBox();
- }
-
- QGeometryData geometry;
- QGLMaterialCollection *palette;
- QMatrix4x4 localTransform;
- QVector3D translate;
- QList<QGraphicsTransform3D *> transforms;
- QGL::StandardEffect localEffect;
- QGLAbstractEffect *customEffect;
- QList<QGLSceneNode*> childNodes;
- QList<QGLSceneNode*> parentNodes;
- bool hasEffect;
- int material;
- int backMaterial;
- int start;
- int count;
- QGLSceneNode::Options options;
- QGLPickNode *pickNode;
- mutable QBox3D bb;
- mutable bool boxValid;
- QGL::DrawingMode drawingMode;
- qreal drawingWidth;
- bool culled;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGLSCENENODE_P_H
diff --git a/src/threed/scene/scene.pri b/src/threed/scene/scene.pri
deleted file mode 100644
index 289f6b9c..00000000
--- a/src/threed/scene/scene.pri
+++ /dev/null
@@ -1,19 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += scene/qglabstractscene.h \
- scene/qglsceneformatplugin.h \
- scene/qglscenenode.h \
- scene/qglpicknode.h \
- scene/qglrendersequencer.h \
- scene/qglrenderorder.h \
- scene/qglrenderordercomparator.h \
- scene/qglrenderstate.h
-SOURCES += qglabstractscene.cpp \
- qglsceneformatplugin.cpp \
- qglscenenode.cpp \
- qglpicknode.cpp \
- qglrendersequencer.cpp \
- qglrenderorder.cpp \
- qglrenderordercomparator.cpp \
- qglrenderstate.cpp
-PRIVATE_HEADERS += qglscenenode_p.h
diff --git a/src/threed/surfaces/qglabstractsurface.cpp b/src/threed/surfaces/qglabstractsurface.cpp
deleted file mode 100644
index 9e2bf216..00000000
--- a/src/threed/surfaces/qglabstractsurface.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglabstractsurface.h"
-#include "qglcontextsurface_p.h"
-#include "qglframebufferobjectsurface.h"
-#include "qglpixelbuffersurface.h"
-#include "qglsubsurface.h"
-#include "qglwidgetsurface.h"
-#include <QtGui/qpaintdevice.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLAbstractSurface
- \brief The QGLAbstractSurface class represents an OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-
- OpenGL can be used to draw into a number of different surface types:
- windows, pixel buffers (pbuffers), framebuffer objects, and so on.
- It is also possible to use only part of a surface by setting
- the \c{glViewport()} to restrict drawing to that part. An example
- of a subsurface may be the left or right eye image of a stereoscopic
- pair that is rendered into the two halves of a window.
-
- Activating a surface for OpenGL drawing, and deactivating it afterwards
- can be quite varied across surface types. Sometimes it is enough
- to just make a QGLContext current and set the \c{glViewport()}.
- Other times a context must be made current, followed by binding a
- framebuffer object, and finally setting the \c{glViewport()}.
-
- QGLAbstractSurface and its subclasses simplify the activation and
- deactivation of surfaces by encapsulating the logic needed to
- use a particular kind of surface into activate() and deactivate()
- respectively.
-
- Normally surfaces are activated by calling QGLPainter::pushSurface()
- as in the following example of switching drawing to a framebuffer
- object:
-
- \code
- QGLPainter painter;
- painter.begin(widget);
- QGLFramebufferObjectSurface surface(fbo);
- painter.pushSurface(&surface);
- ... // draw into the fbo
- painter.popSurface();
- ... // draw into the widget
- \endcode
-
- QGLPainter maintains a stack of surfaces, starting with the paint
- device specified to QGLPainter::begin() (usually a widget).
- The QGLPainter::pushSurface() function calls deactivate() on the
- current surface, activate() on the new surface, and then adjusts the
- \c{glViewport()} to match the value of viewportGL() for the new surface.
- When QGLPainter::popSurface() is called, the previous surface
- is re-activated and the \c{glViewport()} changed accordingly.
-
- \sa QGLFramebufferObjectSurface, QGLWidgetSurface, QGLSubsurface
- \sa QGLPixelBufferSurface, QGLPainter::pushSurface()
-*/
-
-/*!
- \enum QGLAbstractSurface::SurfaceType
- This enum defines the type of a QGLAbstractSurface.
-
- \value Widget Instance of QGLWidgetSurface.
- \value FramebufferObject Instance of QGLFramebufferObjectSurface.
- \value PixelBuffer Instance of QGLPixelBufferSurface.
- \value Subsurface Instance of QGLSubsurface.
- \value User First user-defined surface type for use by applications.
-*/
-
-/*!
- \fn QGLAbstractSurface::QGLAbstractSurface(int surfaceType)
-
- Constructs an OpenGL drawing surface of the specified \a surfaceType.
-*/
-
-/*!
- Destroys this OpenGL drawing surface.
-*/
-QGLAbstractSurface::~QGLAbstractSurface()
-{
-}
-
-/*!
- \fn int QGLAbstractSurface::surfaceType() const
-
- Returns the type of this surface.
-*/
-
-/*!
- \fn QPaintDevice *QGLAbstractSurface::device() const
-
- Returns the raw device that this surface will draw on.
-
- If the surface is an instance of QGLSubsurface, then this will
- return the device of the surface that underlies the subsurface.
- The viewportRect() defines the region to render into.
-
- \sa viewportRect()
-*/
-
-/*!
- \fn bool QGLAbstractSurface::activate(QGLAbstractSurface *prevSurface)
-
- Activate this surface by making its context current, and binding
- the associated framebuffer object, if any.
-
- If \a prevSurface is null, then that surface has just been deactivated
- in the process of switching to this surface. This may allow activate()
- to optimize the transition to avoid unnecessary state changes.
-
- Returns true if the surface was activated; false otherwise.
-
- \sa deactivate(), switchTo()
-*/
-
-/*!
- \fn void QGLAbstractSurface::deactivate(QGLAbstractSurface *nextSurface)
-
- Deactivate this surface from the current context, but leave the
- context current. Typically this will release the framebuffer
- object associated with the surface.
-
- If \a nextSurface is null, then that surface will be activated next
- in the process of switching away from this surface. This may allow
- deactivate() to optimize the transition to avoid unnecessary state
- changes.
-
- \sa activate(), switchTo()
-*/
-
-/*!
- Returns the rectangle of the surface device() that is occupied by
- the viewport for this surface. The origin is at the top-left.
-
- This function calls viewportGL() and then flips the rectangle
- upside down using the height of device() so that the origin
- is at the top-left instead of the bottom-right.
-
- \sa viewportGL(), device()
-*/
-QRect QGLAbstractSurface::viewportRect() const
-{
- QRect view = viewportGL();
- QPaintDevice *dev = device();
- int height;
- if (dev->devType() == QInternal::Widget)
- height = static_cast<QWidget *>(dev)->height();
- else
- height = dev->height();
- return QRect(view.x(), height - (view.y() + view.height()),
- view.width(), view.height());
-}
-
-/*!
- \fn QRect QGLAbstractSurface::viewportGL() const
-
- Returns the rectangle of the surface device() that is occupied by
- the viewport for this surface. The origin is at the bottom-left,
- which makes the value suitable for passing to \c{glViewport()}:
-
- \code
- QRect viewport = surface->viewportGL();
- glViewport(viewport.x(), viewport.y(), viewport.width(), viewport.height());
- \endcode
-
- Normally the viewport rectangle is the full extent of the device(),
- but it could be smaller if the application only wishes to draw
- into a subpart of the device(). An example would be rendering left
- and right stereo eye images into the two halves of a QGLWidget.
- The eye surfaces would typically be instances of QGLSubsurface.
-
- \sa viewportRect(), device()
-*/
-
-/*!
- Returns the aspect ratio of viewportGL() after correcting for the
- DPI of device().
-
- The return value is used to correct perspective and orthographic
- projections for the aspect ratio of the drawing surface. Subclasses
- may override this function to adjust the return value if the DPI of
- device() is not sufficient to determine the aspect ratio.
-*/
-qreal QGLAbstractSurface::aspectRatio() const
-{
- // Get the size of the current viewport.
- QSize size = viewportGL().size();
- if (size.width() == 0 || size.height() == 0 ||
- size.width() == size.height())
- return 1.0f;
-
- // Use the device's DPI setting to determine the pixel aspect ratio.
- QPaintDevice *device = this->device();
- int dpiX = device->logicalDpiX();
- int dpiY = device->logicalDpiY();
- if (dpiX <= 0 || dpiY <= 0)
- dpiX = dpiY = 1;
-
- // Return the final aspect ratio based on viewport and pixel size.
- return ((qreal)(size.width() * dpiY)) / ((qreal)(size.height() * dpiX));
-}
-
-/*!
- Switches from this surface to \a nextSurface by calling deactivate()
- on this surface and activate() on \a nextSurface.
-
- Returns true if \a nextSurface was activated, or false otherwise.
- If \a nextSurface could not be activated, then this surface will
- remain activated.
-
- \sa activate(), deactivate()
-*/
-bool QGLAbstractSurface::switchTo(QGLAbstractSurface *nextSurface)
-{
- if (nextSurface) {
- deactivate(nextSurface);
- if (nextSurface->activate(this))
- return true;
- activate();
- return false;
- } else {
- deactivate();
- return true;
- }
-}
-
-/*!
- Creates an OpenGL drawing surface for the specified paint \a device.
- Returns null if it is not possible to create a surface for \a device.
-
- \sa createSurfaceForContext()
-*/
-QGLAbstractSurface *QGLAbstractSurface::createSurfaceForDevice
- (QPaintDevice *device)
-{
- Q_ASSERT(device);
- switch (device->devType()) {
- case QInternal::Widget: {
- QGLWidget *glw = qobject_cast<QGLWidget *>
- (static_cast<QWidget *>(device));
- if (glw)
- return new QGLWidgetSurface(glw);
- else
- return 0;
- }
- case QInternal::Pbuffer:
- return new QGLPixelBufferSurface(static_cast<QGLPixelBuffer *>(device));
- case QInternal::FramebufferObject:
- return new QGLFramebufferObjectSurface
- (static_cast<QGLFramebufferObject *>(device));
- default:
- return 0;
- }
-}
-
-/*!
- Creates an OpenGL drawing surface for the paint device
- underlying \a context. If the paint device is not recognized,
- then a generic surface will be created that makes \a context
- current when the surface is activated.
-
- \sa createSurfaceForDevice()
-*/
-QGLAbstractSurface *QGLAbstractSurface::createSurfaceForContext
- (const QGLContext *context)
-{
- Q_ASSERT(context);
- QGLAbstractSurface *surface = createSurfaceForDevice(context->device());
- if (!surface)
- surface = new QGLContextSurface(context);
- return surface;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglabstractsurface.h b/src/threed/surfaces/qglabstractsurface.h
deleted file mode 100644
index 715abb47..00000000
--- a/src/threed/surfaces/qglabstractsurface.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLABSTRACTSURFACE_H
-#define QGLABSTRACTSURFACE_H
-
-#include "qt3dglobal.h"
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLAbstractSurface
-{
-public:
- virtual ~QGLAbstractSurface();
-
- enum SurfaceType
- {
- Widget,
- FramebufferObject,
- PixelBuffer,
- Subsurface,
- User = 1000
- };
-
- int surfaceType() const { return m_type; }
-
- virtual QPaintDevice *device() const = 0;
- virtual bool activate(QGLAbstractSurface *prevSurface = 0) = 0;
- virtual void deactivate(QGLAbstractSurface *nextSurface = 0) = 0;
- virtual QRect viewportGL() const = 0;
- QRect viewportRect() const;
- virtual qreal aspectRatio() const;
-
- bool switchTo(QGLAbstractSurface *nextSurface);
-
- static QGLAbstractSurface *createSurfaceForDevice(QPaintDevice *device);
- static QGLAbstractSurface *createSurfaceForContext(const QGLContext *context);
-
-protected:
- QGLAbstractSurface(int surfaceType) : m_type(surfaceType) {}
-
-private:
- int m_type;
-
- Q_DISABLE_COPY(QGLAbstractSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglcontextsurface.cpp b/src/threed/surfaces/qglcontextsurface.cpp
deleted file mode 100644
index 98a96f36..00000000
--- a/src/threed/surfaces/qglcontextsurface.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcontextsurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QPaintDevice *QGLContextSurface::device() const
-{
- return m_context->device();
-}
-
-bool QGLContextSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_UNUSED(prevSurface);
- if (QGLContext::currentContext() != m_context)
- const_cast<QGLContext *>(m_context)->makeCurrent();
- return true;
-}
-
-void QGLContextSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- Q_UNUSED(nextSurface);
-}
-
-QRect QGLContextSurface::viewportGL() const
-{
- QPaintDevice *device = m_context->device();
- return QRect(0, 0, device->width(), device->height());
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglcontextsurface_p.h b/src/threed/surfaces/qglcontextsurface_p.h
deleted file mode 100644
index 6c1a8beb..00000000
--- a/src/threed/surfaces/qglcontextsurface_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCONTEXTSURFACE_P_H
-#define QGLCONTEXTSURFACE_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.
-//
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLContextSurface : public QGLAbstractSurface
-{
-public:
- explicit QGLContextSurface(const QGLContext *context)
- : QGLAbstractSurface(502)
- , m_context(context) {}
- ~QGLContextSurface() {}
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface);
- void deactivate(QGLAbstractSurface *nextSurface);
- QRect viewportGL() const;
-
-private:
- const QGLContext *m_context;
-
- Q_DISABLE_COPY(QGLContextSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qgldrawbuffersurface.cpp b/src/threed/surfaces/qgldrawbuffersurface.cpp
deleted file mode 100644
index 11aaa610..00000000
--- a/src/threed/surfaces/qgldrawbuffersurface.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgldrawbuffersurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QPaintDevice *QGLDrawBufferSurface::device() const
-{
- return m_surface->device();
-}
-
-bool QGLDrawBufferSurface::activate(QGLAbstractSurface *prevSurface)
-{
- if (!m_surface->activate(prevSurface))
- return false;
-#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT)
- glDrawBuffer(m_buffer);
-#endif
- return true;
-}
-
-void QGLDrawBufferSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- m_surface->deactivate(nextSurface);
-}
-
-QRect QGLDrawBufferSurface::viewportGL() const
-{
- return m_surface->viewportGL();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qgldrawbuffersurface_p.h b/src/threed/surfaces/qgldrawbuffersurface_p.h
deleted file mode 100644
index 9fe6c2cc..00000000
--- a/src/threed/surfaces/qgldrawbuffersurface_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLDRAWBUFFERSURFACE_P_H
-#define QGLDRAWBUFFERSURFACE_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.
-//
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLDrawBufferSurface : public QGLAbstractSurface
-{
-public:
- QGLDrawBufferSurface(QGLAbstractSurface *surface, GLenum buffer)
- : QGLAbstractSurface(500)
- , m_surface(surface), m_buffer(buffer) {}
- ~QGLDrawBufferSurface() {}
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface);
- void deactivate(QGLAbstractSurface *nextSurface);
- QRect viewportGL() const;
-
-private:
- QGLAbstractSurface *m_surface;
- GLenum m_buffer;
-
- Q_DISABLE_COPY(QGLDrawBufferSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglframebufferobjectsurface.cpp b/src/threed/surfaces/qglframebufferobjectsurface.cpp
deleted file mode 100644
index 99551c26..00000000
--- a/src/threed/surfaces/qglframebufferobjectsurface.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglframebufferobjectsurface.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLFramebufferObjectSurface
- \brief The QGLFramebufferObjectSurface class represents a framebuffer object that is being used as an OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-*/
-
-class QGLFramebufferObjectSurfacePrivate
-{
-public:
- QGLFramebufferObjectSurfacePrivate
- (QGLFramebufferObject *fbo, const QGLContext *ctx)
- : framebufferObject(fbo), context(ctx) {}
-
- QGLFramebufferObject *framebufferObject;
- const QGLContext *context;
-};
-
-/*!
- Constructs a default framebuffer object surface. This constructor
- should be followed by a call to setFramebufferObject().
-*/
-QGLFramebufferObjectSurface::QGLFramebufferObjectSurface()
- : QGLAbstractSurface(QGLAbstractSurface::FramebufferObject)
- , d_ptr(new QGLFramebufferObjectSurfacePrivate(0, 0))
-{
-}
-
-/*!
- Constructs a framebuffer object surface for \a fbo and \a context.
- If \a context is null, then the framebuffer will be bound to the
- current context when activate() is called.
-*/
-QGLFramebufferObjectSurface::QGLFramebufferObjectSurface
- (QGLFramebufferObject *fbo, const QGLContext *context)
- : QGLAbstractSurface(QGLAbstractSurface::FramebufferObject)
- , d_ptr(new QGLFramebufferObjectSurfacePrivate(fbo, context))
-{
-}
-
-/*!
- Destroys this framebuffer object surface.
-*/
-QGLFramebufferObjectSurface::~QGLFramebufferObjectSurface()
-{
-}
-
-/*!
- Returns the context that owns framebufferObject(); or null
- if the framebufferObject() should be assumed to be owned by
- the current context when activate() is called.
-
- \sa setContext(), framebufferObject()
-*/
-const QGLContext *QGLFramebufferObjectSurface::context() const
-{
- Q_D(const QGLFramebufferObjectSurface);
- return d->context;
-}
-
-/*!
- Sets the \a context that owns framebufferObject().
-
- When activate() is called, it checks to see if \a context is sharing
- with the current context. If it is, then the framebufferObject()
- is directly bound to the current context. Otherwise, \a context
- is made current and then framebufferObject() is bound.
-
- If \a context is null, then framebufferObject() will be bound
- to whatever the current context is when activate() is called.
-
- \sa context()
-*/
-void QGLFramebufferObjectSurface::setContext(const QGLContext *context)
-{
- Q_D(QGLFramebufferObjectSurface);
- d->context = context;
-}
-
-/*!
- Returns the framebuffer object for this surface, or null if
- it has not been set yet.
-
- \sa setFramebufferObject(), context()
-*/
-QGLFramebufferObject *QGLFramebufferObjectSurface::framebufferObject() const
-{
- Q_D(const QGLFramebufferObjectSurface);
- return d->framebufferObject;
-}
-
-/*!
- Sets the framebuffer object for this surface to \a fbo.
-
- \sa framebufferObject()
-*/
-void QGLFramebufferObjectSurface::setFramebufferObject
- (QGLFramebufferObject *fbo)
-{
- Q_D(QGLFramebufferObjectSurface);
- d->framebufferObject = fbo;
-}
-
-/*!
- \reimp
-*/
-QPaintDevice *QGLFramebufferObjectSurface::device() const
-{
- Q_D(const QGLFramebufferObjectSurface);
- return d->framebufferObject;
-}
-
-/*!
- \reimp
-*/
-bool QGLFramebufferObjectSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_UNUSED(prevSurface);
- Q_D(QGLFramebufferObjectSurface);
- if (d->context) {
- if (!QGLContext::areSharing(QGLContext::currentContext(), d->context))
- const_cast<QGLContext *>(d->context)->makeCurrent();
- } else {
- // If we don't have a current context, then something is wrong.
- Q_ASSERT(QGLContext::currentContext());
- }
- if (d->framebufferObject)
- return d->framebufferObject->bind();
- return false;
-}
-
-/*!
- \reimp
-*/
-void QGLFramebufferObjectSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- Q_D(QGLFramebufferObjectSurface);
- if (d->framebufferObject) {
- if (nextSurface && nextSurface->surfaceType() == FramebufferObject) {
- // If we are about to switch to another fbo that is on the
- // same context, then don't bother doing the release().
- // This saves an unnecessary glBindFramebuffer(0) call.
- if (static_cast<QGLFramebufferObjectSurface *>(nextSurface)
- ->context() == d->context)
- return;
- }
- d->framebufferObject->release();
- }
-}
-
-/*!
- \reimp
-*/
-QRect QGLFramebufferObjectSurface::viewportGL() const
-{
- Q_D(const QGLFramebufferObjectSurface);
- if (d->framebufferObject)
- return QRect(QPoint(0, 0), d->framebufferObject->size());
- else
- return QRect();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglframebufferobjectsurface.h b/src/threed/surfaces/qglframebufferobjectsurface.h
deleted file mode 100644
index 3135e81f..00000000
--- a/src/threed/surfaces/qglframebufferobjectsurface.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLFRAMEBUFFEROBJECTSURFACE_H
-#define QGLFRAMEBUFFEROBJECTSURFACE_H
-
-#include "qglabstractsurface.h"
-#include <QtOpenGL/qglframebufferobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLFramebufferObjectSurfacePrivate;
-
-class Q_QT3D_EXPORT QGLFramebufferObjectSurface : public QGLAbstractSurface
-{
-public:
- QGLFramebufferObjectSurface();
- explicit QGLFramebufferObjectSurface
- (QGLFramebufferObject *fbo, const QGLContext *context = 0);
- ~QGLFramebufferObjectSurface();
-
- const QGLContext *context() const;
- void setContext(const QGLContext *context);
-
- QGLFramebufferObject *framebufferObject() const;
- void setFramebufferObject(QGLFramebufferObject *fbo);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface = 0);
- void deactivate(QGLAbstractSurface *nextSurface = 0);
- QRect viewportGL() const;
-
-private:
- QScopedPointer<QGLFramebufferObjectSurfacePrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLFramebufferObjectSurface)
- Q_DISABLE_COPY(QGLFramebufferObjectSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglmaskedsurface.cpp b/src/threed/surfaces/qglmaskedsurface.cpp
deleted file mode 100644
index d2d46237..00000000
--- a/src/threed/surfaces/qglmaskedsurface.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglmaskedsurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLMaskedSurface
- \brief The QGLMaskedSurface class represents a masked copy of another OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
- \internal
-
- Masked surfaces are typically used to render red-cyan anaglyph images
- into an underlying surface(). For the left eye image, the mask()
- is set to RedMask | AlphaMask. Then for the right eye image, the mask()
- is set to GreenMask | BlueMask.
-*/
-
-/*!
- \enum QGLMaskedSurface::BufferMaskBit
- This enum defines the channels to mask with QGLMaskedSurface.
-
- \value RedMask Allow the red channel to be written to the color buffer.
- \value GreenMask Allow the green channel to be written to the color buffer.
- \value BlueMask Allow the blue channel to be written to the color buffer.
- \value AlphaMask Allow the alpha channel to be written to the color buffer.
-*/
-
-class QGLMaskedSurfacePrivate
-{
-public:
- QGLMaskedSurfacePrivate
- (QGLAbstractSurface *surf = 0,
- QGLMaskedSurface::BufferMask msk = QGLMaskedSurface::RedMask |
- QGLMaskedSurface::GreenMask |
- QGLMaskedSurface::BlueMask |
- QGLMaskedSurface::AlphaMask)
- : surface(surf), mask(msk) {}
-
- QGLAbstractSurface *surface;
- QGLMaskedSurface::BufferMask mask;
-};
-
-#define MaskedSurfaceType 501
-
-/*!
- Constructs a masked OpenGL drawing surface with surface() initially
- set to null and mask() initially set to allow all channels to be
- written to the color buffer.
-*/
-QGLMaskedSurface::QGLMaskedSurface()
- : QGLAbstractSurface(MaskedSurfaceType)
- , d_ptr(new QGLMaskedSurfacePrivate)
-{
-}
-
-/*!
- Constructs a masked OpenGL drawing surface that applies \a mask
- to \a surface when activate() is called.
-*/
-QGLMaskedSurface::QGLMaskedSurface
- (QGLAbstractSurface *surface, QGLMaskedSurface::BufferMask mask)
- : QGLAbstractSurface(MaskedSurfaceType)
- , d_ptr(new QGLMaskedSurfacePrivate(surface, mask))
-{
-}
-
-/*!
- Destroys this masked OpenGL drawing surface.
-*/
-QGLMaskedSurface::~QGLMaskedSurface()
-{
-}
-
-/*!
- Returns the underlying surface that mask() will be applied to
- when activate() is called.
-
- \sa setSurface(), mask()
-*/
-QGLAbstractSurface *QGLMaskedSurface::surface() const
-{
- Q_D(const QGLMaskedSurface);
- return d->surface;
-}
-
-/*!
- Sets the underlying \a surface that mask() will be applied to
- when activate() is called.
-
- \sa surface(), setMask()
-*/
-void QGLMaskedSurface::setSurface(QGLAbstractSurface *surface)
-{
- Q_D(QGLMaskedSurface);
- d->surface = surface;
-}
-
-/*!
- Returns the color mask to apply to surface() when activate()
- is called.
-
- \sa setMask(), surface()
-*/
-QGLMaskedSurface::BufferMask QGLMaskedSurface::mask() const
-{
- Q_D(const QGLMaskedSurface);
- return d->mask;
-}
-
-/*!
- Sets the color \a mask to apply to surface() when activate()
- is called.
-
- \sa mask(), setSurface()
-*/
-void QGLMaskedSurface::setMask(QGLMaskedSurface::BufferMask mask)
-{
- Q_D(QGLMaskedSurface);
- d->mask = mask;
-}
-
-/*!
- \reimp
-*/
-QPaintDevice *QGLMaskedSurface::device() const
-{
- Q_D(const QGLMaskedSurface);
- return d->surface ? d->surface->device() : 0;
-}
-
-/*!
- \reimp
-*/
-bool QGLMaskedSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_D(const QGLMaskedSurface);
- if (!d->surface || !d->surface->activate(prevSurface))
- return false;
- glColorMask((d->mask & RedMask) != 0, (d->mask & GreenMask) != 0,
- (d->mask & BlueMask) != 0, (d->mask & AlphaMask) != 0);
- return true;
-}
-
-/*!
- \reimp
-*/
-void QGLMaskedSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- Q_D(QGLMaskedSurface);
- if (d->surface)
- d->surface->deactivate(nextSurface);
- if (nextSurface && nextSurface->surfaceType() == MaskedSurfaceType) {
- // If we are about to switch to another masked surface for
- // the same underlying surface, then don't bother calling
- // glColorMask() for this one.
- QGLMaskedSurface *next = static_cast<QGLMaskedSurface *>(nextSurface);
- if (d->surface == next->surface())
- return;
- }
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-}
-
-/*!
- \reimp
-*/
-QRect QGLMaskedSurface::viewportGL() const
-{
- Q_D(const QGLMaskedSurface);
- return d->surface ? d->surface->viewportGL() : QRect();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglmaskedsurface_p.h b/src/threed/surfaces/qglmaskedsurface_p.h
deleted file mode 100644
index b2b0c61d..00000000
--- a/src/threed/surfaces/qglmaskedsurface_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLMASKEDSURFACE_H
-#define QGLMASKEDSURFACE_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.
-//
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLMaskedSurfacePrivate;
-
-class QGLMaskedSurface : public QGLAbstractSurface
-{
-public:
- enum BufferMaskBit
- {
- RedMask = 0x0001,
- GreenMask = 0x0002,
- BlueMask = 0x0004,
- AlphaMask = 0x0008
- };
- Q_DECLARE_FLAGS(BufferMask, BufferMaskBit)
-
- QGLMaskedSurface();
- QGLMaskedSurface
- (QGLAbstractSurface *surface, QGLMaskedSurface::BufferMask mask);
- ~QGLMaskedSurface();
-
- QGLAbstractSurface *surface() const;
- void setSurface(QGLAbstractSurface *surface);
-
- QGLMaskedSurface::BufferMask mask() const;
- void setMask(QGLMaskedSurface::BufferMask mask);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface = 0);
- void deactivate(QGLAbstractSurface *nextSurface = 0);
- QRect viewportGL() const;
-
-private:
- QScopedPointer<QGLMaskedSurfacePrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLMaskedSurface)
- Q_DISABLE_COPY(QGLMaskedSurface)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLMaskedSurface::BufferMask)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglpaintersurface.cpp b/src/threed/surfaces/qglpaintersurface.cpp
deleted file mode 100644
index 98e9d436..00000000
--- a/src/threed/surfaces/qglpaintersurface.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglpaintersurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QPaintDevice *QGLPainterSurface::device() const
-{
- return m_painter->device();
-}
-
-bool QGLPainterSurface::activate(QGLAbstractSurface *prevSurface)
-{
- if (m_painterContext != QGLContext::currentContext())
- const_cast<QGLContext *>(m_painterContext)->makeCurrent();
- if (!prevSurface)
- m_painter->beginNativePainting();
- return true;
-}
-
-void QGLPainterSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- if (!nextSurface)
- m_painter->endNativePainting();
-}
-
-QRect QGLPainterSurface::viewportGL() const
-{
- QPaintDevice *device = m_painter->device();
- return QRect(0, 0, device->width(), device->height());
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglpaintersurface_p.h b/src/threed/surfaces/qglpaintersurface_p.h
deleted file mode 100644
index 0dc49161..00000000
--- a/src/threed/surfaces/qglpaintersurface_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPAINTERSURFACE_P_H
-#define QGLPAINTERSURFACE_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.
-//
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLPainterSurface : public QGLAbstractSurface
-{
-public:
- explicit QGLPainterSurface(QPainter *painter)
- : QGLAbstractSurface(503)
- , m_painter(painter), m_painterContext(QGLContext::currentContext()) {}
- ~QGLPainterSurface() {}
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface);
- void deactivate(QGLAbstractSurface *nextSurface);
- QRect viewportGL() const;
-
-private:
- QPainter *m_painter;
- const QGLContext *m_painterContext;
-
- Q_DISABLE_COPY(QGLPainterSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglpixelbuffersurface.cpp b/src/threed/surfaces/qglpixelbuffersurface.cpp
deleted file mode 100644
index 45735cc3..00000000
--- a/src/threed/surfaces/qglpixelbuffersurface.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglpixelbuffersurface.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLPixelBufferSurface
- \brief The QGLPixelBufferSurface class represents a pixel buffer that is being used as an OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-*/
-
-/*!
- Constructs a default pixel buffer surface. This constructor
- should be followed by a call to setPixelBuffer().
-*/
-QGLPixelBufferSurface::QGLPixelBufferSurface()
- : QGLAbstractSurface(QGLAbstractSurface::PixelBuffer)
- , m_pbuffer(0)
-{
-}
-
-/*!
- Constructs a pixel buffer surface for \a pbuffer.
-*/
-QGLPixelBufferSurface::QGLPixelBufferSurface(QGLPixelBuffer *pbuffer)
- : QGLAbstractSurface(QGLAbstractSurface::PixelBuffer)
- , m_pbuffer(pbuffer)
-{
-}
-
-/*!
- Destroys this pixel buffer surface.
-*/
-QGLPixelBufferSurface::~QGLPixelBufferSurface()
-{
-}
-
-/*!
- Returns the pixel buffer for this surface, or null if
- it has not been set yet.
-
- \sa setPixelBuffer()
-*/
-QGLPixelBuffer *QGLPixelBufferSurface::pixelBuffer() const
-{
- return m_pbuffer;
-}
-
-/*!
- Sets the framebuffer object for this surface to \a pbuffer.
-
- \sa pixelBuffer()
-*/
-void QGLPixelBufferSurface::setPixelBuffer
- (QGLPixelBuffer *pbuffer)
-{
- m_pbuffer = pbuffer;
-}
-
-/*!
- \reimp
-*/
-QPaintDevice *QGLPixelBufferSurface::device() const
-{
- return m_pbuffer;
-}
-
-/*!
- \reimp
-*/
-bool QGLPixelBufferSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_UNUSED(prevSurface);
- if (m_pbuffer)
- return m_pbuffer->makeCurrent();
- else
- return false;
-}
-
-/*!
- \reimp
-*/
-void QGLPixelBufferSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- // Nothing to do here - leave the context current.
- Q_UNUSED(nextSurface);
-}
-
-/*!
- \reimp
-*/
-QRect QGLPixelBufferSurface::viewportGL() const
-{
- if (m_pbuffer)
- return QRect(0, 0, m_pbuffer->width(), m_pbuffer->height());
- else
- return QRect();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglpixelbuffersurface.h b/src/threed/surfaces/qglpixelbuffersurface.h
deleted file mode 100644
index 22dac86c..00000000
--- a/src/threed/surfaces/qglpixelbuffersurface.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLPIXELBUFFERSURFACE_H
-#define QGLPIXELBUFFERSURFACE_H
-
-#include "qglabstractsurface.h"
-#include <QtOpenGL/qglpixelbuffer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QGLPixelBufferSurface : public QGLAbstractSurface
-{
-public:
- QGLPixelBufferSurface();
- explicit QGLPixelBufferSurface(QGLPixelBuffer *pbuffer);
- ~QGLPixelBufferSurface();
-
- QGLPixelBuffer *pixelBuffer() const;
- void setPixelBuffer(QGLPixelBuffer *pbuffer);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface = 0);
- void deactivate(QGLAbstractSurface *nextSurface = 0);
- QRect viewportGL() const;
-
-private:
- QGLPixelBuffer *m_pbuffer;
-
- Q_DISABLE_COPY(QGLPixelBufferSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglsubsurface.cpp b/src/threed/surfaces/qglsubsurface.cpp
deleted file mode 100644
index 367dd621..00000000
--- a/src/threed/surfaces/qglsubsurface.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsubsurface.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLSubsurface
- \brief The QGLSubsurface class represents a sub-surface of another OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-*/
-
-class QGLSubsurfacePrivate
-{
-public:
- QGLSubsurfacePrivate() : surface(0) {}
- QGLSubsurfacePrivate(QGLAbstractSurface *surf, const QRect &rgn)
- : surface(surf), region(rgn) {}
-
- QGLAbstractSurface *surface;
- QRect region;
-};
-
-/*!
- Constructs a new subsurface. This constructor should be followed
- by calls to setSurface() and setRegion().
-*/
-QGLSubsurface::QGLSubsurface()
- : QGLAbstractSurface(QGLAbstractSurface::Subsurface)
- , d_ptr(new QGLSubsurfacePrivate)
-{
-}
-
-/*!
- Constructs a new subsurface that occupies \a region within
- \a surface. The \a region has its origin at the top-left
- of \a surface.
-*/
-QGLSubsurface::QGLSubsurface
- (QGLAbstractSurface *surface, const QRect &region)
- : QGLAbstractSurface(QGLAbstractSurface::Subsurface)
- , d_ptr(new QGLSubsurfacePrivate(surface, region))
-{
-}
-
-/*!
- Destroys this subsurface.
-*/
-QGLSubsurface::~QGLSubsurface()
-{
-}
-
-/*!
- Returns the surface behind this subsurface, or null if the
- surface has not been set.
-
- \sa setSurface(), region()
-*/
-QGLAbstractSurface *QGLSubsurface::surface() const
-{
- Q_D(const QGLSubsurface);
- return d->surface;
-}
-
-/*!
- Sets the \a surface behind this subsurface.
-
- \sa surface(), setRegion()
-*/
-void QGLSubsurface::setSurface(QGLAbstractSurface *surface)
-{
- Q_D(QGLSubsurface);
- d->surface = surface;
-}
-
-/*!
- Returns the region within surface() that is occupied by this
- subsurface, relative to the viewportRect() of surface().
- The origin is at the top-left of surface().
-
- \sa setRegion(), surface()
-*/
-QRect QGLSubsurface::region() const
-{
- Q_D(const QGLSubsurface);
- return d->region;
-}
-
-/*!
- Sets the \a region within surface() that is occupied by this
- subsurface, relative to the viewportRect() of surface().
- The origin is at the top-left of surface().
-
- \sa region(), setSurface()
-*/
-void QGLSubsurface::setRegion(const QRect &region)
-{
- Q_D(QGLSubsurface);
- d->region = region;
-}
-
-/*!
- \reimp
-*/
-QPaintDevice *QGLSubsurface::device() const
-{
- Q_D(const QGLSubsurface);
- if (d->surface)
- return d->surface->device();
- else
- return 0;
-}
-
-/*!
- \reimp
-*/
-bool QGLSubsurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_D(QGLSubsurface);
- if (d->surface)
- return d->surface->activate(prevSurface);
- else
- return false;
-}
-
-/*!
- \reimp
-*/
-void QGLSubsurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- Q_D(QGLSubsurface);
- if (d->surface)
- d->surface->deactivate(nextSurface);
-}
-
-/*!
- \reimp
-*/
-QRect QGLSubsurface::viewportGL() const
-{
- Q_D(const QGLSubsurface);
- if (d->surface) {
- // The underlying surface's viewportGL() has its origin
- // at the bottom-left, whereas d->region has its origin
- // at the top-left. Flip the sub-region and adjust.
- QRect rect = d->surface->viewportGL();
- return QRect(rect.x() + d->region.x(),
- rect.y() + rect.height() -
- (d->region.y() + d->region.height()),
- d->region.width(), d->region.height());
- } else {
- // Don't know the actual height of the surrounding surface,
- // so the best we can do is assume the region is bottom-aligned.
- return QRect(d->region.x(), 0, d->region.width(), d->region.height());
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglsubsurface.h b/src/threed/surfaces/qglsubsurface.h
deleted file mode 100644
index 69904a19..00000000
--- a/src/threed/surfaces/qglsubsurface.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSUBSURFACE_H
-#define QGLSUBSURFACE_H
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLSubsurfacePrivate;
-
-class Q_QT3D_EXPORT QGLSubsurface : public QGLAbstractSurface
-{
-public:
- QGLSubsurface();
- QGLSubsurface(QGLAbstractSurface *surface, const QRect &region);
- ~QGLSubsurface();
-
- QGLAbstractSurface *surface() const;
- void setSurface(QGLAbstractSurface *subSurface);
-
- QRect region() const;
- void setRegion(const QRect &region);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface = 0);
- void deactivate(QGLAbstractSurface *nextSurface = 0);
- QRect viewportGL() const;
-
-private:
- QScopedPointer<QGLSubsurfacePrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QGLSubsurface)
- Q_DISABLE_COPY(QGLSubsurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/qglwidgetsurface.cpp b/src/threed/surfaces/qglwidgetsurface.cpp
deleted file mode 100644
index 7d137eb6..00000000
--- a/src/threed/surfaces/qglwidgetsurface.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglwidgetsurface.h"
-#include <QtGui/qpainter.h>
-#include <QtGui/qpaintengine.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLWidgetSurface
- \brief The QGLWidgetSurface class represents a QGLWidget that is begin used as an OpenGL drawing surface.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::painting
-*/
-
-/*!
- Constructs a widget surface. This constructor should be followed
- by a call to setWidget().
-*/
-QGLWidgetSurface::QGLWidgetSurface()
- : QGLAbstractSurface(QGLAbstractSurface::Widget)
- , m_widget(0)
-{
-}
-
-/*!
- Constructs a widget surface for \a widget.
-*/
-QGLWidgetSurface::QGLWidgetSurface(QGLWidget *widget)
- : QGLAbstractSurface(QGLAbstractSurface::Widget)
- , m_widget(widget)
-{
-}
-
-/*!
- Destroys this widget surface.
-*/
-QGLWidgetSurface::~QGLWidgetSurface()
-{
-}
-
-/*!
- Returns the widget that is underlying this surface.
-
- \sa setWidget()
-*/
-QGLWidget *QGLWidgetSurface::widget() const
-{
- return m_widget;
-}
-
-/*!
- Sets the \a widget that is underlying this surface.
-
- \sa widget()
-*/
-void QGLWidgetSurface::setWidget(QGLWidget *widget)
-{
- m_widget = widget;
-}
-
-/*!
- \reimp
-*/
-QPaintDevice *QGLWidgetSurface::device() const
-{
- return m_widget;
-}
-
-/*!
- \reimp
-*/
-bool QGLWidgetSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_UNUSED(prevSurface);
- if (m_widget) {
- const QGLContext *context = m_widget->context();
- if (QGLContext::currentContext() != context)
- const_cast<QGLContext *>(context)->makeCurrent();
- return true;
- } else {
- return false;
- }
-}
-
-/*!
- \reimp
-*/
-void QGLWidgetSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- // Nothing to do here - leave the context current.
- Q_UNUSED(nextSurface);
-}
-
-/*!
- \reimp
-*/
-QRect QGLWidgetSurface::viewportGL() const
-{
- if (m_widget)
- return m_widget->rect(); // Origin assumed to be (0, 0).
- else
- return QRect();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/surfaces/qglwidgetsurface.h b/src/threed/surfaces/qglwidgetsurface.h
deleted file mode 100644
index e0ce8e27..00000000
--- a/src/threed/surfaces/qglwidgetsurface.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLWIDGETSURFACE_H
-#define QGLWIDGETSURFACE_H
-
-#include "qglabstractsurface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLWidgetSurfacePrivate;
-
-class Q_QT3D_EXPORT QGLWidgetSurface : public QGLAbstractSurface
-{
-public:
- QGLWidgetSurface();
- explicit QGLWidgetSurface(QGLWidget *widget);
- ~QGLWidgetSurface();
-
- QGLWidget *widget() const;
- void setWidget(QGLWidget *widget);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface = 0);
- void deactivate(QGLAbstractSurface *nextSurface = 0);
- QRect viewportGL() const;
-
-private:
- QGLWidget *m_widget;
-
- Q_DISABLE_COPY(QGLWidgetSurface)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/surfaces/surfaces.pri b/src/threed/surfaces/surfaces.pri
deleted file mode 100644
index 8ce35fb6..00000000
--- a/src/threed/surfaces/surfaces.pri
+++ /dev/null
@@ -1,23 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += \
- surfaces/qglabstractsurface.h \
- surfaces/qglframebufferobjectsurface.h \
- surfaces/qglpixelbuffersurface.h \
- surfaces/qglsubsurface.h \
- surfaces/qglwidgetsurface.h
-SOURCES += \
- qglabstractsurface.cpp \
- qglcontextsurface.cpp \
- qgldrawbuffersurface.cpp \
- qglframebufferobjectsurface.cpp \
- qglmaskedsurface.cpp \
- qglpaintersurface.cpp \
- qglpixelbuffersurface.cpp \
- qglsubsurface.cpp \
- qglwidgetsurface.cpp
-PRIVATE_HEADERS += \
- qglcontextsurface_p.h \
- qgldrawbuffersurface_p.h \
- qglmaskedsurface_p.h \
- qglpaintersurface_p.h
diff --git a/src/threed/textures/qareaallocator.cpp b/src/threed/textures/qareaallocator.cpp
deleted file mode 100644
index 79340c1a..00000000
--- a/src/threed/textures/qareaallocator.cpp
+++ /dev/null
@@ -1,877 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qareaallocator.h"
-#include "qglnamespace.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QAreaAllocator
- \brief The QAreaAllocator class provides facilities for allocating sub-regions from a rectangular image.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
- \internal
-
- Performance on a system can sometimes be improved by storing
- multiple small images in a single large image. This reduces
- memory allocation overhead and GPU state switching costs.
-
- QAreaAllocator and its subclasses implement standard strategies
- for sub-region allocation in images without tying those strategies
- to specific technologies such as raster, OpenGL, etc.
-
- Allocations are managed in a virtual two-dimensional space.
- The caller performs the actual texture upload based on the sub-region
- that allocate() returns.
-
- The caller can return a sub-region to the allocation pool with
- release(). Note that not all strategies support release().
-
- \sa QSimpleAreaAllocator, QGeneralAreaAllocator, QUniformAreaAllocator
-*/
-
-/*!
- \class QSimpleAreaAllocator
- \brief The QSimpleAreaAllocator class provides a simple allocation policy for simple-sized sub-allocations.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
- \internal
-
- QSimpleAreaAllocator uses a trivial allocation strategy whereby
- sub-regions are allocated in rows, with a new row started each
- time the previous row fills up. Space is never reclaimed by
- release().
-
- This allocator is suitable for use when the allocations will all
- be of a similar size and all regions will be discarded at
- the same time when the allocator is destroyed. An example would
- be a font glyph manager.
-
- \sa QAreaAllocator, QGeneralAreaAllocator
-*/
-
-/*!
- \class QGeneralAreaAllocator
- \brief The QGeneralAreaAllocator class provides a general allocation policy for sub-regions in an image.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
- \internal
-
- QGeneralAreaAllocator can handle arbitrary-sized allocations up to
- size(), in any order, and can release() previously allocated regions.
- It uses a binary subdivision algorithm on the image, which may result
- in fragmentation under heavy load.
-
- While technically any size sub-region up to size() can be allocated,
- once subdivision begins, the sizes that can be allocated will reduce
- substantially. It is recommended that incoming requests be size() / 4
- or less for best performance.
-
- If the sub-region sizes to be allocated are very similar, and release()
- is not necessary, then QSimpleAreaAllocator may work better than
- QGeneralAreaAllocator. If the sizes are very similar, and
- release() is necessary, then QUniformAreaAllocator may work better
- than QGeneralAreaAllocator.
-
- \sa QAreaAllocator, QSimpleAreaAllocator, QUniformAreaAllocator
-*/
-
-/*!
- \class QUniformAreaAllocator
- \brief The QUniformAreaAllocator class provides an allocation policy for uniform-sized areas.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
- \internal
-
- QUniformAreaAllocator allocates any size up to uniformSize()
- by dividing size() up into a grid of uniformSize() areas.
- Areas can be deallocated with release() and returned to the pool.
-
- This allocator is suitable for use when the allocations will all
- be of a similar size. Unlike QSimpleAreaAllocator, this class
- can release allocations.
-
- \sa QAreaAllocator, QSimpleAreaAllocator, QGeneralAreaAllocator
-*/
-
-/*!
- \internal
-
- Constructs a new area allocator that is initially \a size pixels
- in size.
-
- \sa expand()
-*/
-QAreaAllocator::QAreaAllocator(const QSize &size)
- : m_size(size)
- , m_minAlloc(1, 1)
- , m_margin(0, 0)
-{
-}
-
-/*!
- \internal
-
- Destroys this area allocator.
-*/
-QAreaAllocator::~QAreaAllocator()
-{
-}
-
-/*!
- \fn QSize QAreaAllocator::size() const
- \internal
-
- Returns the current size of the area being used by this allocator.
-*/
-
-/*!
- \fn QSize QAreaAllocator::minimumAllocation() const
- \internal
-
- Returns the minimum allocation size in the x and y directions
- for areas returned by allocate(). The default is (1, 1).
-
- \sa setMinimumAllocation()
-*/
-
-/*!
- \fn void QAreaAllocator::setMinimumAllocation(const QSize &size)
- \internal
-
- Sets the minimum allocation \a size in the x and y directions
- for areas returned by allocate().
-
- For example, setting the minimum allocation to (8, 8) will force
- all allocations to be aligned on an 8-pixel boundary.
-
- \sa minimumAllocation()
-*/
-
-/*!
- \fn QSize QAreaAllocator::margin() const
- \internal
-
- Returns the margin that should be left between allocated items
- in the x and y directions. The default is (0, 0).
-
- This may be needed when using OpenGL textures because of
- rounding errors in the floating-point representation of
- texture co-ordinates. Leaving a small margin between allocations
- can help avoid adjacent images from bleeding into each other.
-
- \sa setMargin()
-*/
-
-/*!
- \fn void QAreaAllocator::setMargin(const QSize &margin)
- \internal
-
- Sets the \a margin that should be left between allocated items
- in the x and y directions.
-
- \sa margin()
-*/
-
-/*!
- \internal
-
- Expands this allocator to encompass the width and height of \a size.
- If the area is already larger, this function does nothing.
-
- The rectangles that were returned for previous allocations will
- remain valid.
-
- \sa expandBy()
-*/
-void QAreaAllocator::expand(const QSize &size)
-{
- int newWidth = qMax(m_size.width(), size.width());
- int newHeight = qMax(m_size.height(), size.height());
- m_size = QSize(newWidth, newHeight);
-}
-
-/*!
- \internal
-
- Expands this allocator by \a size pixels in the x and y directions.
-
- For example, expanding by (0, 128) will add 128 additional pixels
- of height but will leave the width unchanged.
-
- \sa expand()
-*/
-void QAreaAllocator::expandBy(const QSize &size)
-{
- expand(m_size + size);
-}
-
-/*!
- \fn QRect QAreaAllocator::allocate(const QSize &size)
- \internal
-
- Allocates \a size pixels from this allocator and returns the rectangle
- that should be used by the caller. Returns a null rectangle if
- this allocator does not have sufficient space to accommodate \a size.
-
- \sa release()
-*/
-
-/*!
- \internal
-
- Allocates and returns a list of rectangles corresponding to the
- elements of \a sizes. The returned list will have less elements
- than \a sizes if there is insufficient space to accommodate
- all of the allocation requests. The values that are in the returned
- list will be allocated and need to be passed to release() to
- deallocate them.
-
- The default implementation will call the subclass allocate() once
- for each size until all \a sizes have been allocated or an
- allocation fails. Subclasses may override this method to
- reorder the allocations for best-fit.
-
- \sa release()
-*/
-QList<QRect> QAreaAllocator::allocate(const QList<QSize> &sizes)
-{
- QList<QRect> rects;
- QRect rect;
- for (int index = 0; index < sizes.count(); ++index) {
- rect = allocate(sizes[index]);
- if (rect.isNull())
- break;
- rects.append(rect);
- }
- return rects;
-}
-
-/*!
- \internal
-
- Releases the space occupied by \a rect back to the allocator.
- The default implementation does nothing.
-
- The \a rect must have been returned by a previous call to allocate().
- Otherwise the behaviour is undefined.
-
- \sa allocate()
-*/
-void QAreaAllocator::release(const QRect &rect)
-{
- Q_UNUSED(rect);
-}
-
-/*!
- \internal
-
- Releases the space occupied by the members of \a rects back to
- the allocator. The default implementation calls release() for
- each rectangle in the list.
-
- The members of \a rects must have been returned by previous calls
- to allocate(). Otherwise the behaviour is undefined.
-
- \sa allocate()
-*/
-void QAreaAllocator::release(const QList<QRect> &rects)
-{
- for (int index = 0; index < rects.count(); ++index)
- release(rects[index]);
-}
-
-/*!
- \internal
-
- Returns a rough estimate of the number of bytes of overhead that
- are currently in use to store the house-keeping data structures
- for this area allocator. The default implementation returns zero.
-*/
-int QAreaAllocator::overhead() const
-{
- return 0;
-}
-
-/*!
- \internal
-
- Returns \a size, after rounding it up to account for
- minimumAllocation() and margin().
-
- This is a convenience function, provided for subclass overrides
- of allocate().
-
- \sa allocate()
-*/
-QSize QAreaAllocator::roundAllocation(const QSize &size) const
-{
- int width = size.width() + m_margin.width();
- int height = size.height() + m_margin.height();
- int extra = width % m_minAlloc.width();
- if (extra)
- width += m_minAlloc.width() - extra;
- extra = height % m_minAlloc.height();
- if (extra)
- height += m_minAlloc.height() - extra;
- return QSize(width, height);
-}
-
-/*!
- \internal
-
- Constructs a simple area allocator that is initially \a size pixels
- in size.
-*/
-QSimpleAreaAllocator::QSimpleAreaAllocator(const QSize &size)
- : QAreaAllocator(size)
- , m_row(0)
- , m_column(0)
- , m_rowHeight(0)
-{
-}
-
-/*!
- \internal
-
- Destroys this simple area allocator.
-*/
-QSimpleAreaAllocator::~QSimpleAreaAllocator()
-{
-}
-
-/*!
- \internal
-*/
-QRect QSimpleAreaAllocator::allocate(const QSize &size)
-{
- // Round up the allocation size to account for the margin and
- // minimum allocation parameters.
- QSize rounded = roundAllocation(size);
- int width = rounded.width();
- int height = rounded.height();
-
- // Bail out if the size is obviously too small or too big.
- if (width <= 0 || width > m_size.width())
- return QRect();
- if (height <= 0 || height > (m_size.height() - m_row))
- return QRect();
-
- // Do we need to place this allocation on a new row?
- int row = m_row;
- int column = m_column;
- int rowHeight = m_rowHeight;
- if ((column + width) > m_size.width()) {
- row += m_rowHeight;
- column = 0;
- rowHeight = 0;
- if (height > (m_size.height() - row))
- return QRect();
- }
-
- // Update the current allocation position.
- m_row = row;
- m_column = column + width;
- m_rowHeight = qMax(rowHeight, height);
-
- // Return the allocation, using the original size without rounding.
- return QRect(column, row, size.width(), size.height());
-}
-
-/*!
- \internal
-
- Constructs a general area allocator that is initially \a size pixels
- in size. The \a size will be rounded up to the next power of two,
- to simplify the internal allocation policy.
-
- This constructor sets minimumAllocation() to (8, 8) to reduce the
- housekeeping overhead of the internal data structures.
-*/
-QGeneralAreaAllocator::QGeneralAreaAllocator(const QSize &size)
- : QAreaAllocator(QGL::nextPowerOfTwo(size))
-{
- m_root = new Node();
- m_root->rect = QRect(0, 0, m_size.width(), m_size.height());
- m_root->largestFree = m_size;
- m_root->parent = 0;
- m_root->left = 0;
- m_root->right = 0;
- m_nodeCount = 1;
- setMinimumAllocation(QSize(8, 8));
-}
-
-/*!
- \internal
-
- Destroys this general area allocator.
-*/
-QGeneralAreaAllocator::~QGeneralAreaAllocator()
-{
- freeNode(m_root);
-}
-
-/*!
- \internal
-*/
-void QGeneralAreaAllocator::freeNode(Node *node)
-{
- if (node) {
- freeNode(node->left);
- freeNode(node->right);
- }
- delete node;
-}
-
-/*!
- \internal
-
- The \a size will be rounded up to the next power of two.
- Use size() to determine the actual size after expansion.
-*/
-void QGeneralAreaAllocator::expand(const QSize &size)
-{
- QAreaAllocator::expand(QGL::nextPowerOfTwo(size));
-
- if (m_root->rect.size() == m_size)
- return; // No change.
- if (!m_root->left && m_root->largestFree.width() > 0) {
- // No allocations have occurred, so just adjust the root size.
- m_root->rect = QRect(0, 0, m_size.width(), m_size.height());
- m_root->largestFree = m_size;
- return;
- }
-
- // Add extra nodes above the current root to expand the tree.
- Node *oldRoot = m_root;
- Split split;
- if (m_size.width() >= m_size.height())
- split = SplitOnX;
- else
- split = SplitOnY;
- while (m_root->rect.size() != m_size) {
- if (m_root->rect.width() == m_size.width())
- split = SplitOnY;
- else if (m_root->rect.height() == m_size.height())
- split = SplitOnX;
- Node *parent = new Node();
- Node *right = new Node();
- m_nodeCount += 2;
- m_root->parent = parent;
- parent->parent = 0;
- parent->left = m_root;
- parent->right = right;
- parent->largestFree = m_root->rect.size();
- right->parent = parent;
- right->left = 0;
- right->right = 0;
- right->largestFree = m_root->rect.size();
- if (split == SplitOnX) {
- parent->rect = QRect(m_root->rect.x(), m_root->rect.y(),
- m_root->rect.width() * 2,
- m_root->rect.height());
- right->rect = QRect(m_root->rect.x() + m_root->rect.width(),
- m_root->rect.y(),
- m_root->rect.width(), m_root->rect.height());
- } else {
- parent->rect = QRect(m_root->rect.x(), m_root->rect.y(),
- m_root->rect.width(),
- m_root->rect.height() * 2);
- right->rect = QRect(m_root->rect.x(),
- m_root->rect.y() + m_root->rect.width(),
- m_root->rect.width(), m_root->rect.height());
- }
- split = (split == SplitOnX ? SplitOnY : SplitOnX);
- m_root = parent;
- }
- updateLargestFree(oldRoot);
-}
-
-static inline bool fitsWithin(const QSize &size1, const QSize &size2)
-{
- return size1.width() <= size2.width() && size1.height() <= size2.height();
-}
-
-/*!
- \internal
-*/
-QRect QGeneralAreaAllocator::allocate(const QSize &size)
-{
- QSize rounded = roundAllocation(size);
- rounded = QGL::nextPowerOfTwo(rounded);
- if (rounded.width() <= 0 || rounded.width() > m_size.width() ||
- rounded.height() <= 0 || rounded.height() > m_size.height())
- return QRect();
- QPoint point = allocateFromNode(rounded, m_root);
- if (point.x() >= 0)
- return QRect(point, size);
- else
- return QRect();
-}
-
-/*!
- \internal
-*/
-QPoint QGeneralAreaAllocator::allocateFromNode(const QSize &size, Node *node)
-{
- // Find the best node to insert into, which should be
- // a node with the least amount of unused space that is
- // big enough to contain the requested size.
- while (node != 0) {
- // Go down a level and determine if the left or right
- // sub-tree contains the best chance of allocation.
- Node *left = node->left;
- Node *right = node->right;
- if (left && fitsWithin(size, left->largestFree)) {
- if (right && fitsWithin(size, right->largestFree)) {
- if (left->largestFree.width() < right->largestFree.width() ||
- left->largestFree.height() < right->largestFree.height()) {
- // The largestFree values may be a little oversized,
- // so try the left sub-tree and then the right sub-tree.
- QPoint point = allocateFromNode(size, left);
- if (point.x() >= 0)
- return point;
- else
- return allocateFromNode(size, right);
- } else {
- node = right;
- }
- } else {
- node = left;
- }
- } else if (right && fitsWithin(size, right->largestFree)) {
- node = right;
- } else if (left || right) {
- // Neither sub-node has enough space to allocate from.
- return QPoint(-1, -1);
- } else if (fitsWithin(size, node->largestFree)) {
- // Do we need to split this node into smaller pieces?
- Split split;
- if (fitsWithin(QSize(size.width() * 2, size.height() * 2),
- node->largestFree)) {
- // Split in either direction: choose the inverse of
- // the parent node's split direction to try to balance
- // out the wasted space as further subdivisions happen.
- if (node->parent &&
- node->parent->left->rect.x() ==
- node->parent->right->rect.x())
- split = SplitOnX;
- else if (node->parent)
- split = SplitOnY;
- else if (node->rect.width() >= node->rect.height())
- split = SplitOnX;
- else
- split = SplitOnY;
- } else if (fitsWithin(QSize(size.width() * 2, size.height()),
- node->largestFree)) {
- // Split along the X direction.
- split = SplitOnX;
- } else if (fitsWithin(QSize(size.width(), size.height() * 2),
- node->largestFree)) {
- // Split along the Y direction.
- split = SplitOnY;
- } else {
- // Cannot split further - allocate this node.
- node->largestFree = QSize(0, 0);
- updateLargestFree(node);
- return node->rect.topLeft();
- }
-
- // Split the node, then go around again using the left sub-tree.
- node = splitNode(node, split);
- } else {
- // Cannot possibly fit into this node.
- break;
- }
- }
- return QPoint(-1, -1);
-}
-
-/*!
- \internal
-*/
-QGeneralAreaAllocator::Node *QGeneralAreaAllocator::splitNode
- (Node *node, Split split)
-{
- Node *left = new Node();
- Node *right = new Node();
- m_nodeCount += 2;
- left->parent = node;
- left->left = 0;
- left->right = 0;
- right->parent = node;
- right->left = 0;
- right->right = 0;
- node->left = left;
- node->right = right;
- if (split == SplitOnX) {
- left->rect = QRect(node->rect.x(), node->rect.y(),
- node->rect.width() / 2,
- node->rect.height());
- right->rect = QRect(left->rect.right() + 1, node->rect.y(),
- node->rect.width() / 2,
- node->rect.height());
- } else {
- left->rect = QRect(node->rect.x(), node->rect.y(),
- node->rect.width(),
- node->rect.height() / 2);
- right->rect = QRect(node->rect.x(), left->rect.bottom() + 1,
- node->rect.width(),
- node->rect.height() / 2);
- }
- left->largestFree = left->rect.size();
- right->largestFree = right->rect.size();
- node->largestFree = right->largestFree;
- return left;
-}
-
-/*!
- \internal
-*/
-void QGeneralAreaAllocator::updateLargestFree(Node *node)
-{
- while ((node = node->parent) != 0) {
- node->largestFree =
- QSize(qMax(node->left->largestFree.width(),
- node->right->largestFree.width()),
- qMax(node->left->largestFree.height(),
- node->right->largestFree.height()));
- }
-}
-
-/*!
- \internal
-*/
-void QGeneralAreaAllocator::release(const QRect &rect)
-{
- // Locate the node that contains the allocated region.
- Node *node = m_root;
- QPoint point = rect.topLeft();
- while (node != 0) {
- if (node->left && node->left->rect.contains(point))
- node = node->left;
- else if (node->right && node->right->rect.contains(point))
- node = node->right;
- else if (node->rect.contains(point))
- break;
- else
- return; // Point is completely outside the tree.
- }
- if (!node)
- return;
-
- // Mark the node as free and then work upwards through the tree
- // recombining and deleting nodes until we reach a sibling
- // that is still allocated.
- node->largestFree = node->rect.size();
- while (node->parent) {
- if (node->parent->left == node) {
- if (node->parent->right->largestFree !=
- node->parent->right->rect.size())
- break;
- } else {
- if (node->parent->left->largestFree !=
- node->parent->left->rect.size())
- break;
- }
- node = node->parent;
- freeNode(node->left);
- freeNode(node->right);
- m_nodeCount -= 2;
- node->left = 0;
- node->right = 0;
- node->largestFree = node->rect.size();
- }
-
- // Make the rest of our ancestors have the correct "largest free size".
- updateLargestFree(node);
-}
-
-/*!
- \internal
-*/
-int QGeneralAreaAllocator::overhead() const
-{
- return m_nodeCount * sizeof(Node);
-}
-
-/*!
- \internal
-
- Constructs a uniform area allocator that is initially \a size pixels
- in size. The \a uniformSize specifies the single allocation size
- that is supported. All allocate() requests must be \a uniformSize
- or less.
-*/
-QUniformAreaAllocator::QUniformAreaAllocator
- (const QSize &size, const QSize &uniformSize)
- : QAreaAllocator(size), m_uniformSize(uniformSize), m_firstFree(0)
-{
- Q_ASSERT(uniformSize.width() > 0 && uniformSize.height() > 0);
- Q_ASSERT(size.width() >= uniformSize.width() &&
- size.height() >= uniformSize.height());
- m_gridSize = QSize(size.width() / uniformSize.width(),
- size.height() / uniformSize.height());
- int count = m_gridSize.width() * m_gridSize.height();
- m_grid = new int [count];
- for (int index = 0; index < (count - 1); ++index)
- m_grid[index] = index + 1;
- m_grid[count - 1] = -1;
-}
-
-/*!
- \internal
-
- Destroys this uniform area allocator.
-*/
-QUniformAreaAllocator::~QUniformAreaAllocator()
-{
- delete [] m_grid;
-}
-
-/*!
- \fn QSize QUniformAreaAllocator::uniformSize() const
- \internal
-
- Returns the uniform size of all allocations.
-
- \sa allocate()
-*/
-
-/*!
- \internal
-*/
-void QUniformAreaAllocator::expand(const QSize &size)
-{
- QAreaAllocator::expand(size);
-
- QSize newGridSize = QSize(m_size.width() / m_uniformSize.width(),
- m_size.height() / m_uniformSize.height());
- if (m_gridSize == newGridSize)
- return;
-
- // Create a new grid.
- int newCount = newGridSize.width() * newGridSize.height();
- int *newGrid = new int [newCount];
-
- // Copy across the free blocks from the old grid.
- int posn = m_firstFree;
- int newFirstFree = -1;
- while (posn != -1) {
- int x = posn % m_gridSize.width();
- int y = posn / m_gridSize.width();
- int newPosn = x + y * newGridSize.width();
- newGrid[newPosn] = newFirstFree;
- newFirstFree = newPosn;
- posn = m_grid[posn];
- }
-
- // Add free blocks within the expanded area of the new grid.
- for (int y = 0; y < m_gridSize.height(); ++y) {
- int newPosn = y * newGridSize.width() + m_gridSize.width();
- for (int x = m_gridSize.width(); x < newGridSize.width(); ++x) {
- newGrid[newPosn] = newFirstFree;
- newFirstFree = newPosn;
- ++newPosn;
- }
- }
- for (int y = m_gridSize.height(); y < newGridSize.height(); ++y) {
- int newPosn = y * newGridSize.width();
- for (int x = 0; x < newGridSize.width(); ++x) {
- newGrid[newPosn] = newFirstFree;
- newFirstFree = newPosn;
- ++newPosn;
- }
- }
-
- // Replace the old grid.
- delete [] m_grid;
- m_grid = newGrid;
- m_gridSize = newGridSize;
- m_firstFree = newFirstFree;
-}
-
-/*!
- \internal
-*/
-QRect QUniformAreaAllocator::allocate(const QSize &size)
-{
- QSize rounded = roundAllocation(size);
- if (rounded.width() > m_uniformSize.width() ||
- rounded.height() > m_uniformSize.height())
- return QRect();
- int posn = m_firstFree;
- if (posn == -1)
- return QRect();
- m_firstFree = m_grid[posn];
- int x = posn % m_gridSize.width();
- int y = posn / m_gridSize.width();
- return QRect(x * m_uniformSize.width(), y * m_uniformSize.height(),
- size.width(), size.height());
-}
-
-/*!
- \internal
-*/
-void QUniformAreaAllocator::release(const QRect &rect)
-{
- int x = rect.x() / m_uniformSize.width();
- int y = rect.y() / m_uniformSize.height();
- int posn = x + y * m_gridSize.width();
- Q_ASSERT(posn >= 0 && posn < m_gridSize.width() * m_gridSize.height());
- m_grid[posn] = m_firstFree;
- m_firstFree = posn;
-}
-
-/*!
- \internal
-*/
-int QUniformAreaAllocator::overhead() const
-{
- return sizeof(int) * m_gridSize.width() * m_gridSize.height();
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/textures/qareaallocator.h b/src/threed/textures/qareaallocator.h
deleted file mode 100644
index f861b500..00000000
--- a/src/threed/textures/qareaallocator.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QAREAALLOCATOR_P_H
-#define QAREAALLOCATOR_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.
-//
-
-#include "qt3dglobal.h"
-#include <QtCore/qsize.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class Q_QT3D_EXPORT QAreaAllocator
-{
-public:
- QAreaAllocator(const QSize &size);
- virtual ~QAreaAllocator();
-
- QSize size() const { return m_size; }
-
- QSize minimumAllocation() const { return m_minAlloc; }
- void setMinimumAllocation(const QSize &size) { m_minAlloc = size; }
-
- QSize margin() const { return m_margin; }
- void setMargin(const QSize &margin) { m_margin = margin; }
-
- virtual void expand(const QSize &size);
- void expandBy(const QSize &size);
-
- virtual QRect allocate(const QSize &size) = 0;
- virtual QList<QRect> allocate(const QList<QSize> &sizes);
- virtual void release(const QRect &rect);
- virtual void release(const QList<QRect> &rects);
-
- virtual int overhead() const;
-
-protected:
- QSize m_size;
- QSize m_minAlloc;
- QSize m_margin;
-
- QSize roundAllocation(const QSize &size) const;
-};
-
-class Q_QT3D_EXPORT QSimpleAreaAllocator : public QAreaAllocator
-{
-public:
- QSimpleAreaAllocator(const QSize &size);
- virtual ~QSimpleAreaAllocator();
-
- QRect allocate(const QSize &size);
-
-private:
- int m_row;
- int m_column;
- int m_rowHeight;
-};
-
-class Q_QT3D_EXPORT QGeneralAreaAllocator : public QAreaAllocator
-{
-public:
- QGeneralAreaAllocator(const QSize &size);
- virtual ~QGeneralAreaAllocator();
-
- void expand(const QSize &size);
- QRect allocate(const QSize &size);
- void release(const QRect &rect);
- int overhead() const;
-
-private:
- enum Split { SplitOnX, SplitOnY };
-
- struct Node
- {
- QRect rect;
- QSize largestFree;
- Node *parent;
- Node *left;
- Node *right;
- };
-
- Node *m_root;
- int m_nodeCount;
-
- static void freeNode(Node *node);
- QPoint allocateFromNode(const QSize &size, Node *node);
- Node *splitNode(Node *node, Split split);
- static void updateLargestFree(Node *node);
-};
-
-class Q_QT3D_EXPORT QUniformAreaAllocator : public QAreaAllocator
-{
-public:
- QUniformAreaAllocator(const QSize &size, const QSize &uniformSize);
- virtual ~QUniformAreaAllocator();
-
- QSize uniformSize() const { return m_uniformSize; }
-
- void expand(const QSize &size);
- QRect allocate(const QSize &size);
- void release(const QRect &rect);
- int overhead() const;
-
-private:
- QSize m_uniformSize;
- QSize m_gridSize;
- int *m_grid;
- int m_firstFree;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/textures/qglsharedresource.cpp b/src/threed/textures/qglsharedresource.cpp
deleted file mode 100644
index ab6d0101..00000000
--- a/src/threed/textures/qglsharedresource.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglsharedresource_p.h"
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_MOC_RUN)
-
-class Q_OPENGL_EXPORT QGLSignalProxy : public QObject
-{
- Q_OBJECT
-public:
- QGLSignalProxy() : QObject() {}
- void emitAboutToDestroyContext(const QGLContext *context) {
- emit aboutToDestroyContext(context);
- }
- static QGLSignalProxy *instance();
-Q_SIGNALS:
- void aboutToDestroyContext(const QGLContext *context);
-};
-
-#endif
-
-class QGLContextInfo
-{
-public:
- QGLContextInfo(const QGLContext *ctx) : m_context(ctx), m_resources(0) {}
- ~QGLContextInfo();
-
- const QGLContext *m_context;
- QGLSharedResource *m_resources;
-};
-
-QGLContextInfo::~QGLContextInfo()
-{
- // Detach this information block from all of the shared resources
- // that used to be owned by it.
- QGLSharedResource *resource = m_resources;
- while (resource != 0) {
- resource->m_contextInfo = 0;
- resource->m_id = 0;
- resource = resource->m_next;
- }
-}
-
-class QGLContextManager : public QObject
-{
- Q_OBJECT
-public:
- QGLContextManager(QObject *parent = 0);
- ~QGLContextManager();
-
- QMutex managerLock;
-
- QGLContextInfo *contextInfo(const QGLContext *ctx);
-
-private Q_SLOTS:
- void aboutToDestroyContext(const QGLContext *ctx);
-
-private:
- QList<QGLContextInfo *> m_contexts;
-};
-
-Q_GLOBAL_STATIC(QGLContextManager, qt_gl_context_manager)
-
-QGLContextManager::QGLContextManager(QObject *parent)
- : QObject(parent)
-{
- QGLSignalProxy *proxy = QGLSignalProxy::instance();
- QThread *mainThread = qApp->thread();
- if (thread() != mainThread) {
- // The manager and signal proxy have been created for the first
- // time in a background thread. For safety, move both objects
- // to the main thread.
- moveToThread(mainThread);
- proxy->moveToThread(mainThread);
- }
- connect(proxy, SIGNAL(aboutToDestroyContext(const QGLContext *)),
- this, SLOT(aboutToDestroyContext(const QGLContext *)));
-}
-
-QGLContextManager::~QGLContextManager()
-{
- QMutexLocker locker(&managerLock);
- qDeleteAll(m_contexts);
-}
-
-QGLContextInfo *QGLContextManager::contextInfo(const QGLContext *ctx)
-{
- QGLContextInfo *info;
- for (int index = 0; index < m_contexts.size(); ++index) {
- info = m_contexts[index];
- if (info->m_context == ctx)
- return info;
- }
- info = new QGLContextInfo(ctx);
- m_contexts.append(info);
- return info;
-}
-
-Q_OPENGL_EXPORT const QGLContext *qt_gl_transfer_context(const QGLContext *);
-
-void QGLContextManager::aboutToDestroyContext(const QGLContext *ctx)
-{
- QMutexLocker locker(&managerLock);
- int index = 0;
- while (index < m_contexts.size()) {
- QGLContextInfo *info = m_contexts[index];
- if (info->m_context == ctx) {
- const QGLContext *transfer = qt_gl_transfer_context(ctx);
- if (transfer) {
- // Transfer ownership to another context in the same sharing
- // group. This may result in multiple QGLContextInfo objects
- // for the same context, which is ok.
- info->m_context = transfer;
- } else {
- // All contexts in the sharing group have been deleted,
- // so detach all of the shared resources.
- m_contexts.removeAt(index);
- delete info;
- continue;
- }
- }
- ++index;
- }
-}
-
-const QGLContext *QGLSharedResource::context() const
-{
- // Hope that the context will not be destroyed in another thread
- // while we are doing this so we don't have to acquire the lock.
- return m_contextInfo ? m_contextInfo->m_context : 0;
-}
-
-void QGLSharedResource::attach(const QGLContext *context, GLuint id)
-{
- Q_ASSERT(!m_contextInfo);
- QGLContextManager *manager = qt_gl_context_manager();
- QMutexLocker locker(&(manager->managerLock));
- m_contextInfo = manager->contextInfo(context);
- m_id = id;
- m_next = m_contextInfo->m_resources;
- m_prev = 0;
- if (m_contextInfo->m_resources)
- m_contextInfo->m_resources->m_prev = this;
- m_contextInfo->m_resources = this;
-}
-
-void QGLSharedResource::destroy()
-{
- // Detach this resource from the context information block.
- QGLContextManager *manager = qt_gl_context_manager();
- const QGLContext *owner = 0;
- GLuint id = 0;
- manager->managerLock.lock();
- if (m_contextInfo) {
- if (m_next)
- m_next->m_prev = m_prev;
- if (m_prev)
- m_prev->m_next = m_next;
- else
- m_contextInfo->m_resources = m_next;
- owner = m_contextInfo->m_context;
- id = m_id;
- }
- m_contextInfo = 0;
- m_id = 0;
- m_next = 0;
- m_prev = 0;
- manager->managerLock.unlock();
-
- // Switch back to the owning context temporarily and delete the id.
- if (owner && id) {
- QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext());
- QGLContext *oldContext;
- QGLContext *doneContext;
- if (currentContext != owner && !QGLContext::areSharing(owner, currentContext)) {
- oldContext = currentContext;
- doneContext = const_cast<QGLContext *>(owner);
- doneContext->makeCurrent();
- } else {
- oldContext = 0;
- doneContext = 0;
- }
- m_destroyFunc(id);
- if (oldContext)
- oldContext->makeCurrent();
- else if (!currentContext && doneContext)
- doneContext->doneCurrent();
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qglsharedresource.moc"
diff --git a/src/threed/textures/qglsharedresource_p.h b/src/threed/textures/qglsharedresource_p.h
deleted file mode 100644
index 2e03c9fa..00000000
--- a/src/threed/textures/qglsharedresource_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLSHAREDRESOURCE_P_H
-#define QGLSHAREDRESOURCE_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.
-//
-
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLContextManager;
-class QGLContextInfo;
-
-class QGLSharedResource
-{
-public:
- typedef void (*DestroyResourceFunc)(GLuint id);
- QGLSharedResource(DestroyResourceFunc destroyFunc)
- : m_destroyFunc(destroyFunc), m_contextInfo(0), m_id(0)
- , m_next(0), m_prev(0) {}
- ~QGLSharedResource() { destroy(); }
-
- const QGLContext *context() const;
- GLuint id() const { return m_id; }
- void clearId() { m_id = 0; }
-
- void attach(const QGLContext *context, GLuint id);
- void destroy();
-
-private:
- DestroyResourceFunc m_destroyFunc;
- QGLContextInfo *m_contextInfo;
- GLuint m_id;
- QGLSharedResource *m_next;
- QGLSharedResource *m_prev;
-
- friend class QGLContextManager;
- friend class QGLContextInfo;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/textures/qgltexture2d.cpp b/src/threed/textures/qgltexture2d.cpp
deleted file mode 100644
index 07fe9891..00000000
--- a/src/threed/textures/qgltexture2d.cpp
+++ /dev/null
@@ -1,805 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgltexture2d.h"
-#include "qgltexture2d_p.h"
-#include "qgltextureutils_p.h"
-#include "qglpainter_p.h"
-#include "qglext_p.h"
-#include "qabstractdownloadmanager.h"
-#include "qdownloadmanager.h"
-#include "qthreadeddownloadmanager.h"
-#include "qopenglfunctions.h"
-
-#include <QtCore/qfile.h>
-#include <QtCore/qfileinfo.h>
-#include <QImageReader>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLTexture2D
- \brief The QGLTexture2D class represents a 2D texture object for GL painting operations.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
-
- QGLTexture2D contains a QImage and settings for texture filters,
- wrap modes, and mipmap generation. When bind() is called, this
- information is uploaded to the GL server if it has changed since
- the last time bind() was called.
-
- Once a QGLTexture2D object is created, it can be bound to multiple
- GL contexts. Internally, a separate texture identifier is created
- for each context. This makes QGLTexture2D easier to use than
- raw GL texture identifiers because the application does not need
- to be as concerned with whether the texture identifier is valid
- in the current context. The application merely calls bind() and
- QGLTexture2D will create a new texture identifier for the context
- if necessary.
-
- QGLTexture2D internally points to a reference-counted object that
- represents the current texture state. If the QGLTexture2D is copied,
- the internal pointer is the same. Modifications to one QGLTexture2D
- copy will affect all of the other copies in the system.
-
- The texture identifiers will be destroyed when the last QGLTexture2D
- reference is destroyed, or when a context is destroyed that contained a
- texture identifier that was created by QGLTexture2D.
-
- QGLTexture2D can also be used for uploading 1D textures into the
- GL server by specifying an image() with a height of 1.
-
- \sa QGLTextureCube
-*/
-
-Q_GLOBAL_STATIC(QSize, getMaxImageSize)
-
-QGLTexture2DPrivate::ForcePowerOfTwo QGLTexture2DPrivate::forcePowerOfTwo = QGLTexture2DPrivate::ForcePowerOfTwoUndefined;
-
-QGLTexture2DPrivate::QGLTexture2DPrivate()
-{
- horizontalWrap = QGL::Repeat;
- verticalWrap = QGL::Repeat;
- bindOptions = QGLContext::DefaultBindOption;
-#if !defined(QT_OPENGL_ES)
- mipmapSupported = false;
- mipmapSupportedKnown = false;
-#endif
- imageGeneration = 0;
- parameterGeneration = 0;
- infos = 0;
- downloadManager = 0;
-
- if (forcePowerOfTwo == ForcePowerOfTwoUndefined) {
- if (qgetenv("NPOT_MIPMAP_UNSUPPORTED").toInt() == 1)
- forcePowerOfTwo = ForcePowerOfTwoTrue;
- else
- forcePowerOfTwo = ForcePowerOfTwoFalse;
- }
-}
-
-QGLTexture2DPrivate::~QGLTexture2DPrivate()
-{
- // Destroy the texture id's in the GL server in their original contexts.
- QGLTexture2DTextureInfo *current = infos;
- QGLTexture2DTextureInfo *next;
- const QGLContext *currentContext =
- const_cast<QGLContext *>(QGLContext::currentContext());
- const QGLContext *firstContext = currentContext;
- while (current != 0) {
- next = current->next;
- if (current->isLiteral)
- current->tex.clearId(); // Don't delete literal id's.
- delete current;
- current = next;
- }
- if (firstContext != currentContext) {
- if (firstContext)
- const_cast<QGLContext *>(firstContext)->makeCurrent();
- else if (currentContext)
- const_cast<QGLContext *>(currentContext)->doneCurrent();
- }
-}
-
-/*!
- Constructs a null texture object and attaches it to \a parent.
-
- \sa isNull()
-*/
-QGLTexture2D::QGLTexture2D(QObject *parent)
- : QObject(parent), d_ptr(new QGLTexture2DPrivate())
-{
-}
-
-/*!
- Destroys this texture object. If this object is the last
- reference to the underlying GL texture, then the underlying
- GL texture will also be deleted.
-*/
-QGLTexture2D::~QGLTexture2D()
-{
-}
-
-/*!
- Returns true if this texture object is null; that is, image()
- is null and textureId() is zero.
-*/
-bool QGLTexture2D::isNull() const
-{
- Q_D(const QGLTexture2D);
- return d->image.isNull() && !d->infos;
-}
-
-/*!
- Returns true if this texture has an alpha channel; false if the
- texture is fully opaque.
-*/
-bool QGLTexture2D::hasAlphaChannel() const
-{
- Q_D(const QGLTexture2D);
- if (!d->image.isNull())
- return d->image.hasAlphaChannel();
- QGLTexture2DTextureInfo *info = d->infos;
- if (info)
- return info->tex.hasAlpha();
- return false;
-}
-
-/*!
- Returns the size of this texture. If the underlying OpenGL
- implementation requires texture sizes to be a power of two,
- then this function will return the next power of two equal
- to or greater than requestedSize()
-
- \sa setSize(), requestedSize()
-*/
-QSize QGLTexture2D::size() const
-{
- Q_D(const QGLTexture2D);
- return d->size;
-}
-
-/*!
- Sets the size of this texture to \a value. If the underlying
- OpenGL implementation requires texture sizes to be a power of
- two, then requestedSize() will be set to \a value, and the
- actual size will be set to the next power of two equal
- to or greater than \a value. Otherwise both size() and
- requestedSize() will be set to \a value.
-
- \sa size(), requestedSize()
-*/
-void QGLTexture2D::setSize(const QSize& value)
-{
- Q_D(QGLTexture2D);
- if (d->requestedSize == value)
- return;
- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
- && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))
- d->size = QGL::nextPowerOfTwo(value);
- else
- d->size = value;
- d->requestedSize = value;
- ++(d->imageGeneration);
-}
-
-/*!
- Returns the size that was previously set with setSize() before
- it was rounded to a power of two.
-
- \sa size(), setSize()
-*/
-QSize QGLTexture2D::requestedSize() const
-{
- Q_D(const QGLTexture2D);
- return d->requestedSize;
-}
-
-/*!
- Returns the image that is currently associated with this texture.
- The image may not have been uploaded into the GL server yet.
- Uploads occur upon the next call to bind().
-
- \sa setImage()
-*/
-QImage QGLTexture2D::image() const
-{
- Q_D(const QGLTexture2D);
- return d->image;
-}
-
-/*!
- Sets the \a image that is associated with this texture. The image
- will be uploaded into the GL server the next time bind() is called.
-
- If setSize() or setImage() has been called previously, then \a image
- will be scaled to size() when it is uploaded.
-
- If \a image is null, then this function is equivalent to clearImage().
-
- \sa image(), setSize(), copyImage(), setPixmap()
-*/
-void QGLTexture2D::setImage(const QImage& image)
-{
- Q_D(QGLTexture2D);
- d->compressedData = QByteArray(); // Clear compressed file data.
- if (image.isNull()) {
- // Don't change the imageGeneration, because we aren't actually
- // changing the image in the GL server, only the client copy.
- d->image = image;
- } else {
- if (image.size().isValid())
- setSize(image.size());
- d->image = image;
- ++(d->imageGeneration);
- }
-}
-
-/*!
- Sets the image that is associated with this texture to \a pixmap.
-
- This is a convenience that calls setImage() after converting
- \a pixmap into a QImage. It may be more efficient on some
- platforms than the application calling QPixmap::toImage().
-
- \sa setImage()
-*/
-void QGLTexture2D::setPixmap(const QPixmap& pixmap)
-{
- QImage image = pixmap.toImage();
- if (pixmap.depth() == 16 && !image.hasAlphaChannel()) {
- // If the system depth is 16 and the pixmap doesn't have an alpha channel
- // then we convert it to RGB16 in the hope that it gets uploaded as a 16
- // bit texture which is much faster to access than a 32-bit one.
- image = image.convertToFormat(QImage::Format_RGB16);
- }
- setImage(image);
-}
-
-/*!
- Clears the image() that is associated with this texture, but the
- GL texture will retain its current value. This can be used to
- release client-side memory that is no longer required once the
- image has been uploaded into the GL server.
-
- The following code will queue \c image to be uploaded, immediately
- force it to be uploaded into the current GL context, and then
- clear the client copy:
-
- \code
- texture.setImage(image);
- texture.bind();
- texture.clearImage()
- \endcode
-
- \sa image(), setImage()
-*/
-void QGLTexture2D::clearImage()
-{
- Q_D(QGLTexture2D);
- d->image = QImage();
-}
-
-#ifndef GL_GENERATE_MIPMAP_SGIS
-#define GL_GENERATE_MIPMAP_SGIS 0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
-#endif
-
-/*!
- Sets this texture to the contents of a compressed image file
- at \a path. Returns true if the file exists and has a supported
- compressed format; false otherwise.
-
- The DDS, ETC1, PVRTC2, and PVRTC4 compression formats are
- supported, assuming that the GL implementation has the
- appropriate extension.
-
- \sa setImage(), setSize()
-*/
-bool QGLTexture2D::setCompressedFile(const QString &path)
-{
- Q_D(QGLTexture2D);
- d->image = QImage();
- QFile f(path);
- if (!f.open(QIODevice::ReadOnly))
- {
- qWarning("QGLTexture2D::setCompressedFile(%s): File could not be read",
- qPrintable(path));
- return false;
- }
- QByteArray data = f.readAll();
- f.close();
-
- bool hasAlpha, isFlipped;
- if (!QGLBoundTexture::canBindCompressedTexture
- (data.constData(), data.size(), 0, &hasAlpha, &isFlipped)) {
- qWarning("QGLTexture2D::setCompressedFile(%s): Format is not supported",
- path.toLocal8Bit().constData());
- return false;
- }
-
- QFileInfo fi(path);
- d->url = QUrl::fromLocalFile(fi.absoluteFilePath());
-
- // The 3DS loader expects the flip state to be set before bind().
- if (isFlipped)
- d->bindOptions &= ~QGLContext::InvertedYBindOption;
- else
- d->bindOptions |= QGLContext::InvertedYBindOption;
-
- d->compressedData = data;
- ++(d->imageGeneration);
- return true;
-}
-
-/*!
- Returns the url that was last set with setUrl.
-*/
-QUrl QGLTexture2D::url() const
-{
- Q_D(const QGLTexture2D);
- return d->url;
-}
-
-/*!
- Sets this texture to have the contents of the image stored at \a url.
-
- If the environment variable QT3D_MULTITHREAD is defined, network urls
- (http, etc) are downloaded in a separate download thread, otherwise they are
- downloaded asynchronously in the current thread.
-*/
-void QGLTexture2D::setUrl(const QUrl &url)
-{
- Q_D(QGLTexture2D);
- if (d->url == url)
- return;
- d->url = url;
-
- if (url.isEmpty())
- {
- d->image = QImage();
- }
- else
- {
- if (url.scheme() == QLatin1String("file") || url.scheme().toLower() == QLatin1String("qrc"))
- {
- QString fileName = url.toLocalFile();
-
- // slight hack since there doesn't appear to be a QUrl::toResourcePath() function
- // to convert qrc:///foo into :/foo
- if (url.scheme().toLower() == QLatin1String("qrc")) {
- // strips off any qrc: prefix and any excess slashes and replaces it with :/
- QUrl tempUrl(url);
- tempUrl.setScheme("");
- fileName = QLatin1String(":")+tempUrl.toString();
- }
-
- if (fileName.endsWith(QLatin1String(".dds"), Qt::CaseInsensitive))
- {
- setCompressedFile(fileName);
- }
- else
- {
- QImageReader imgReader;
- imgReader.setFileName(fileName);
-
- if (!getMaxImageSize()->isValid()) {
- imgReader.setScaledSize(imgReader.size().boundedTo(*getMaxImageSize()));
- }
-
- QImage im = imgReader.read();
- if (im.isNull())
- qWarning("Could not load texture: %s", qPrintable(fileName));
- setImage(im);
- }
- }
- else
- {
- if (!d->downloadManager) {
- if (getenv(QT3D_MULTITHREAD)) {
- //Download in a multithreaded environment
- d->downloadManager = new QThreadedDownloadManager();
- } else {
- //Download in a single threaded environment
- d->downloadManager = new QDownloadManager();
- }
- connect (d->downloadManager,SIGNAL(downloadComplete(QByteArray)),this, SLOT(textureRequestFinished(QByteArray)));
- }
-
- //Create a temporary image that will be used until the Url is loaded.
- static QImage tempImg(128,128, QImage::Format_RGB32);
- QColor fillcolor(Qt::gray);
- tempImg.fill(fillcolor.rgba());
- setImage(tempImg);
-
- if (!d->downloadManager->beginDownload(QUrl(url.toString()))) {
- qWarning("Unable to issue texture download request.");
- }
- }
- }
-}
-
-/*!
- Copies the contents of \a image to \a offset in this texture
- within the current GL context.
-
- Unlike setImage(), this function copies the image data to the
- GL server immediately using \c{glTexSubImage2D()}. This is typically
- used to update the contents of a texture after it has been created.
-
- It is assumed that the application has already called bind() on
- this texture to bind it to the current GL context.
-
- If the texture has been created in multiple contexts, only the
- texture identifier for the current context will be updated.
-
- \sa setImage(), bind()
-*/
-void QGLTexture2D::copyImage(const QImage& image, const QPoint& offset)
-{
- QImage img = QGLWidget::convertToGLFormat(image);
- glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x(), offset.y(),
- img.width(), img.height(), GL_RGBA,
- GL_UNSIGNED_BYTE, img.bits());
-#if defined(QT_OPENGL_ES_2)
- Q_D(QGLTexture2D);
- if (d->bindOptions & QGLContext::MipmapBindOption)
- glGenerateMipmap(GL_TEXTURE_2D);
-#endif
-}
-
-/*!
- Returns the options to use when binding the image() to an OpenGL
- context for the first time. The default options are
- QGLContext::LinearFilteringBindOption |
- QGLContext::InvertedYBindOption | QGLContext::MipmapBindOption.
-
- \sa setBindOptions()
-*/
-QGLContext::BindOptions QGLTexture2D::bindOptions() const
-{
- Q_D(const QGLTexture2D);
- return d->bindOptions;
-}
-
-/*!
- Sets the \a options to use when binding the image() to an
- OpenGL context. If the image() has already been bound,
- then changing the options will cause it to be recreated
- from image() the next time bind() is called.
-
- \sa bindOptions(), bind()
-*/
-void QGLTexture2D::setBindOptions(QGLContext::BindOptions options)
-{
- Q_D(QGLTexture2D);
- if (d->bindOptions != options) {
- d->bindOptions = options;
- ++(d->imageGeneration);
- }
-}
-
-/*!
- Returns the wrapping mode for horizontal texture co-ordinates.
- The default value is QGL::Repeat.
-
- \sa setHorizontalWrap(), verticalWrap()
-*/
-QGL::TextureWrap QGLTexture2D::horizontalWrap() const
-{
- Q_D(const QGLTexture2D);
- return d->horizontalWrap;
-}
-
-/*!
- Sets the wrapping mode for horizontal texture co-ordinates to \a value.
-
- If \a value is not supported by the OpenGL implementation, it will be
- replaced with a value that is supported. If the application desires a
- very specific \a value, it can call horizontalWrap() to check that
- the specific value was actually set.
-
- The \a value will not be applied to the texture in the GL
- server until the next call to bind().
-
- \sa horizontalWrap(), setVerticalWrap()
-*/
-void QGLTexture2D::setHorizontalWrap(QGL::TextureWrap value)
-{
- Q_D(QGLTexture2D);
- value = qt_gl_modify_texture_wrap(value);
- if (d->horizontalWrap != value) {
- d->horizontalWrap = value;
- ++(d->parameterGeneration);
- }
-}
-
-/*!
- Returns the wrapping mode for vertical texture co-ordinates.
- The default value is QGL::Repeat.
-
- \sa setVerticalWrap(), horizontalWrap()
-*/
-QGL::TextureWrap QGLTexture2D::verticalWrap() const
-{
- Q_D(const QGLTexture2D);
- return d->verticalWrap;
-}
-
-/*!
- Sets the wrapping mode for vertical texture co-ordinates to \a value.
-
- If \a value is not supported by the OpenGL implementation, it will be
- replaced with a value that is supported. If the application desires a
- very specific \a value, it can call verticalWrap() to check that
- the specific value was actually set.
-
- The \a value will not be applied to the texture in the GL
- server until the next call to bind().
-
- \sa verticalWrap(), setHorizontalWrap()
-*/
-void QGLTexture2D::setVerticalWrap(QGL::TextureWrap value)
-{
- Q_D(QGLTexture2D);
- value = qt_gl_modify_texture_wrap(value);
- if (d->verticalWrap != value) {
- d->verticalWrap = value;
- ++(d->parameterGeneration);
- }
-}
-
-/*!
- Binds this texture to the 2D texture target.
-
- If this texture object is not associated with an identifier in
- the current context, then a new identifier will be created,
- and image() uploaded into the GL server.
-
- If setImage() or setSize() was called since the last upload,
- then image() will be re-uploaded to the GL server.
-
- Returns false if the texture could not be bound for some reason.
-
- \sa release(), textureId(), setImage()
-*/
-bool QGLTexture2D::bind() const
-{
- Q_D(const QGLTexture2D);
- return const_cast<QGLTexture2DPrivate *>(d)->bind(GL_TEXTURE_2D);
-}
-
-bool QGLTexture2DPrivate::bind(GLenum target)
-{
- // Get the current context. If we don't have one, then we
- // cannot bind the texture.
- const QGLContext *ctx = QGLContext::currentContext();
- if (!ctx)
- return false;
-
- QOpenGLFunctions glFuncs(ctx);
- if (!glFuncs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures))
- {
- QSize oldSize = size;
- size = QGL::nextPowerOfTwo(size);
- if (size != oldSize)
- ++imageGeneration;
- }
-
- // Find the information block for the context, or create one.
- QGLTexture2DTextureInfo *info = infos;
- QGLTexture2DTextureInfo *prev = 0;
- while (info != 0 && !QGLContext::areSharing(info->tex.context(), ctx)) {
- if (info->isLiteral)
- return false; // Cannot create extra texture id's for literals.
- prev = info;
- info = info->next;
- }
- if (!info) {
- info = new QGLTexture2DTextureInfo
- (ctx, 0, imageGeneration - 1, parameterGeneration - 1);
- if (prev)
- prev->next = info;
- else
- infos = info;
- }
-
- if (!info->tex.textureId() || imageGeneration != info->imageGeneration) {
- // Create the texture contents and upload a new image.
- info->tex.setOptions(bindOptions);
- if (!compressedData.isEmpty()) {
- info->tex.bindCompressedTexture
- (compressedData.constData(), compressedData.size());
- } else {
- info->tex.startUpload(ctx, target, image.size());
- bindImages(info);
- info->tex.finishUpload(target);
- }
- info->imageGeneration = imageGeneration;
- } else {
- // Bind the existing texture to the texture target.
- glBindTexture(target, info->tex.textureId());
- }
-
- // If the parameter generation has changed, then alter the parameters.
- if (parameterGeneration != info->parameterGeneration) {
- info->parameterGeneration = parameterGeneration;
- q_glTexParameteri(target, GL_TEXTURE_WRAP_S, horizontalWrap);
- q_glTexParameteri(target, GL_TEXTURE_WRAP_T, verticalWrap);
- }
-
- // Texture is ready to be used.
- return true;
-}
-
-void QGLTexture2DPrivate::bindImages(QGLTexture2DTextureInfo *info)
-{
- QSize scaledSize(size);
-#if defined(QT_OPENGL_ES_2)
- if ((bindOptions & QGLContext::MipmapBindOption) ||
- horizontalWrap != QGL::ClampToEdge ||
- verticalWrap != QGL::ClampToEdge) {
- // ES 2.0 does not support NPOT textures when mipmaps are in use,
- // or if the wrap mode isn't ClampToEdge.
- scaledSize = QGL::nextPowerOfTwo(scaledSize);
- }
-#endif
-
- if (forcePowerOfTwo == ForcePowerOfTwoTrue)
- scaledSize = QGL::nextPowerOfTwo(scaledSize);
-
- if (!image.isNull())
- info->tex.uploadFace(GL_TEXTURE_2D, image, scaledSize);
- else if (size.isValid())
- info->tex.createFace(GL_TEXTURE_2D, scaledSize);
-}
-
-/*!
- Releases the texture associated with the 2D texture target.
- This is equivalent to \c{glBindTexture(GL_TEXTURE_2D, 0)}.
-
- \sa bind()
-*/
-void QGLTexture2D::release() const
-{
- glBindTexture(GL_TEXTURE_2D, 0);
-}
-
-/*!
- Returns the identifier associated with this texture object in
- the current context.
-
- Returns zero if the texture has not previously been bound to
- the 2D texture target in the current context with bind().
-
- \sa bind()
-*/
-GLuint QGLTexture2D::textureId() const
-{
- Q_D(const QGLTexture2D);
- const QGLContext *ctx = QGLContext::currentContext();
- if (!ctx)
- return 0;
- QGLTexture2DTextureInfo *info = d->infos;
- while (info != 0 && !QGLContext::areSharing(info->tex.context(), ctx))
- info = info->next;
- return info ? info->tex.textureId() : 0;
-}
-
-/*!
- Constructs a QGLTexture2D object that wraps the supplied literal
- texture identifier \a id, with the dimensions specified by \a size.
-
- The \a id is assumed to have been created by the application in
- the current GL context, and it will be destroyed by the application
- after the returned QGLTexture2D object is destroyed.
-
- This function is intended for interfacing to existing code that
- uses raw GL texture identifiers. The returned QGLTexture2D can
- only be used with the current GL context.
-
- \sa textureId()
-*/
-QGLTexture2D *QGLTexture2D::fromTextureId(GLuint id, const QSize& size)
-{
- const QGLContext *ctx = QGLContext::currentContext();
- if (!id || !ctx)
- return 0;
-
- QGLTexture2D *texture = new QGLTexture2D();
- if (!size.isNull())
- texture->setSize(size);
- QGLTexture2DTextureInfo *info = new QGLTexture2DTextureInfo
- (ctx, id, texture->d_ptr->imageGeneration,
- texture->d_ptr->parameterGeneration, true);
- texture->d_ptr->infos = info;
- return texture;
-}
-
-/*!
- This slot is used to recieve signals from the QDownloadManager class
- which provides Url download capability across the network.
-
- A successful download will have a valid QByteArray stored in \a assetData,
- while a failed download (due to network error, etc), will result in
- a NULL value.
-
- Successful downloads use the image data downloaded into \a assetData,
- which is converted to an image/texture, and emit a textureUpdated()
- signal.
-
- \sa QDownloadManager
-*/
-void QGLTexture2D::textureRequestFinished(QByteArray assetData)
-{
- //Ensure valid asset data exists.
- if (assetData.isEmpty()) {
- qWarning("Network request failed. Texture not loaded.");
- } else {
- //Convert asset data to an image.
- QImage texImage;
- texImage.loadFromData(assetData);
- setImage(texImage.mirrored());
-
- emit textureUpdated();
- }
-}
-
-/*!
- Sets the maximum size of an image file loaded in a texture as being
- of \a width x \a height in size.
-
- \sa setUrl()
-*/
-void QGLTexture2D::setMaxImageSize(int width, int height)
-{
- Q_ASSERT(width>0 && height>0);
- (*getMaxImageSize()) = QSize(width, height);
-}
-
-/*!
- \fn QGLTexture2D::textureUpdated()
- Signals that some property of this texture has changed in a manner
- that may require that the parent material class be updated.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/threed/textures/qgltexture2d.h b/src/threed/textures/qgltexture2d.h
deleted file mode 100644
index 0513848a..00000000
--- a/src/threed/textures/qgltexture2d.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEXTURE2D_H
-#define QGLTEXTURE2D_H
-
-#include "qglnamespace.h"
-#include <QtOpenGL/qgl.h>
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLTexture2DPrivate;
-
-class Q_QT3D_EXPORT QGLTexture2D : public QObject
-{
- Q_OBJECT
-public:
- QGLTexture2D(QObject *parent = 0);
- ~QGLTexture2D();
-
- bool isNull() const;
- bool hasAlphaChannel() const;
-
- QSize size() const;
- void setSize(const QSize& value);
- QSize requestedSize() const;
-
- QImage image() const;
- void setImage(const QImage& image);
- bool setCompressedFile(const QString &path);
- QUrl url() const;
- void setUrl(const QUrl &url);
-
- void setPixmap(const QPixmap& pixmap);
-
- void clearImage();
-
- void copyImage(const QImage& image, const QPoint& offset = QPoint(0, 0));
-
- QGLContext::BindOptions bindOptions() const;
- void setBindOptions(QGLContext::BindOptions options);
-
- QGL::TextureWrap horizontalWrap() const;
- void setHorizontalWrap(QGL::TextureWrap value);
-
- QGL::TextureWrap verticalWrap() const;
- void setVerticalWrap(QGL::TextureWrap value);
-
- bool bind() const;
- void release() const;
-
- GLuint textureId() const;
-
- static void setMaxImageSize(int width, int height);
-
- static QGLTexture2D *fromTextureId(GLuint id, const QSize& size);
-signals:
- void textureUpdated();
-public slots:
- void textureRequestFinished(QByteArray);
-private:
- QScopedPointer<QGLTexture2DPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGLTexture2D)
- Q_DECLARE_PRIVATE(QGLTexture2D)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/textures/qgltexture2d_p.h b/src/threed/textures/qgltexture2d_p.h
deleted file mode 100644
index 0e9ac634..00000000
--- a/src/threed/textures/qgltexture2d_p.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEXTURE2D_P_H
-#define QGLTEXTURE2D_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.
-//
-
-#include "qgltexture2d.h"
-#include "qgltextureutils_p.h"
-#include "qurl.h"
-#include <QtCore/qatomic.h>
-
-QT_BEGIN_NAMESPACE
-
-class QAbstractDownloadManager;
-
-class QGLTexture2DTextureInfo
-{
-public:
- QGLTexture2DTextureInfo
- (const QGLContext *context, GLuint textureId, uint imageGeneration,
- uint parameterGeneration, bool isLiteral = false)
- {
- if (textureId)
- tex.setTextureId(context, textureId);
- this->imageGeneration = imageGeneration;
- this->parameterGeneration = parameterGeneration;
- this->isLiteral = isLiteral;
- this->next = 0;
- }
-
- QGLBoundTexture tex;
- uint imageGeneration;
- uint parameterGeneration;
- bool isLiteral;
- QGLTexture2DTextureInfo *next;
-};
-
-class DDSFormat;
-
-class QGLTexture2DPrivate
-{
-public:
- QGLTexture2DPrivate();
- ~QGLTexture2DPrivate();
-
- QSize size;
- QSize requestedSize;
- QImage image;
- QUrl url;
- QByteArray compressedData;
- QGLContext::BindOptions bindOptions;
- QGL::TextureWrap horizontalWrap;
- QGL::TextureWrap verticalWrap;
-#if !defined(QT_OPENGL_ES)
- bool mipmapSupported;
- bool mipmapSupportedKnown;
-#endif
- uint imageGeneration;
- uint parameterGeneration;
- QGLTexture2DTextureInfo *infos;
- QAbstractDownloadManager *downloadManager;
-
- enum ForcePowerOfTwo {
- ForcePowerOfTwoUndefined = -1,
- ForcePowerOfTwoFalse = 0,
- ForcePowerOfTwoTrue = 1
- };
-
- static ForcePowerOfTwo forcePowerOfTwo;
-
- bool bind(GLenum target);
- virtual void bindImages(QGLTexture2DTextureInfo *info);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/textures/qgltexturecube.cpp b/src/threed/textures/qgltexturecube.cpp
deleted file mode 100644
index f9587462..00000000
--- a/src/threed/textures/qgltexturecube.cpp
+++ /dev/null
@@ -1,549 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgltexturecube.h"
-#include "qgltexture2d_p.h"
-#include "qgltextureutils_p.h"
-#include "qglpainter_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLTextureCube
- \brief The QGLTextureCube class represents a cube map texture object for GL painting operations.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::textures
-
- QGLTextureCube contains six QImage objects for each of the cube
- map faces and settings for texture filters, wrap modes, and mipmap
- generation. When bind() is called, this information is uploaded to
- the GL server if it has changed since the last time bind() was called.
-
- Once a QGLTextureCube object is created, it can be bound to multiple
- GL contexts. Internally, a separate texture identifier is created
- for each context. This makes QGLTextureCube easier to use than
- raw GL texture identifiers because the application does not need
- to be as concerned with whether the texture identifier is valid
- in the current context. The application merely calls bind() and
- QGLTextureCube will create a new texture identifier for the context
- if necessary.
-
- QGLTextureCube internally points to a reference-counted object that
- represents the current texture state. If the QGLTextureCube is copied,
- the internal pointer is the same. Modifications to one QGLTextureCube
- copy will affect all of the other copies in the system.
-
- The texture identifiers will be destroyed when the last QGLTextureCube
- reference is destroyed, or when a context is destroyed that contained a
- texture identifier that was created by QGLTextureCube.
-
- \sa QGLTexture2D
-*/
-
-/*!
- \enum QGLTextureCube::Face
- This enum defines the face of a cube map texture that is affected
- by a texture operation on QGLTextureCube instances.
-
- \value PositiveX The positive X face of the cube map.
- \value NegativeX The negative X face of the cube map.
- \value PositiveY The positive Y face of the cube map.
- \value NegativeY The negative Y face of the cube map.
- \value PositiveZ The positive Z face of the cube map.
- \value NegativeZ The negative Z face of the cube map.
-*/
-
-class QGLTextureCubePrivate : public QGLTexture2DPrivate
-{
-public:
- QGLTextureCubePrivate();
- ~QGLTextureCubePrivate();
-
- void bindImages(QGLTexture2DTextureInfo *info);
-
- QImage otherImages[5];
- uint changedFaces;
-};
-
-QGLTextureCubePrivate::QGLTextureCubePrivate()
-{
- changedFaces = 0;
-}
-
-QGLTextureCubePrivate::~QGLTextureCubePrivate()
-{
-}
-
-void QGLTextureCubePrivate::bindImages(QGLTexture2DTextureInfo *info)
-{
- QSize scaledSize(size);
-#if defined(QT_OPENGL_ES_2)
- if ((bindOptions & QGLContext::MipmapBindOption) ||
- horizontalWrap != QGL::ClampToEdge ||
- verticalWrap != QGL::ClampToEdge) {
- // ES 2.0 does not support NPOT textures when mipmaps are in use,
- // or if the wrap mode isn't ClampToEdge.
- scaledSize = QGL::nextPowerOfTwo(scaledSize);
- }
-#endif
-
- // Handle the first face.
- if (!image.isNull())
- info->tex.uploadFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X, image, scaledSize);
- else if (size.isValid())
- info->tex.createFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X, scaledSize);
-
- // Handle the other faces.
- for (int face = 1; face < 6; ++face) {
- if (!otherImages[face - 1].isNull()) {
- info->tex.uploadFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
- otherImages[face - 1], scaledSize);
- } else {
- info->tex.createFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, scaledSize);
- }
- }
-}
-
-/*!
- Constructs a null texture object.
-
- \sa isNull()
-*/
-QGLTextureCube::QGLTextureCube()
- : d_ptr(new QGLTextureCubePrivate())
-{
-}
-
-/*!
- Destroys this texture object. If this object is the last
- reference to the underlying GL texture, then the underlying
- GL texture will also be deleted.
-*/
-QGLTextureCube::~QGLTextureCube()
-{
-}
-
-/*!
- Returns true if this texture object is null; that is, all image()
- values are null and textureId() is zero.
-*/
-bool QGLTextureCube::isNull() const
-{
- // TODO
- Q_D(const QGLTextureCube);
- return !d->infos;
-}
-
-/*!
- Returns true if this texture has an alpha channel; false if the
- texture is fully opaque.
-*/
-bool QGLTextureCube::hasAlphaChannel() const
-{
- Q_D(const QGLTextureCube);
- if (!d->image.isNull() && d->image.hasAlphaChannel())
- return true;
- for (int face = 0; face < 5; ++face) {
- if (!d->otherImages[face].isNull()) {
- if (d->otherImages[face].hasAlphaChannel())
- return true;
- }
- }
- QGLTexture2DTextureInfo *info = d->infos;
- if (info)
- return info->tex.hasAlpha();
- return false;
-}
-
-/*!
- Returns the size of this texture. If the underlying OpenGL
- implementation requires texture sizes to be a power of two,
- then this function will return the next power of two equal
- to or greater than requestedSize()
-
- \sa setSize(), requestedSize()
-*/
-QSize QGLTextureCube::size() const
-{
- Q_D(const QGLTextureCube);
- return d->size;
-}
-
-/*!
- Sets the size of this texture to \a value. If the underlying
- OpenGL implementation requires texture sizes to be a power of
- two, then requestedSize() will be set to \a value, and the
- actual size will be set to the next power of two equal
- to or greater than \a value. Otherwise both size() and
- requestedSize() will be set to \a value.
-
- \sa size(), requestedSize()
-*/
-void QGLTextureCube::setSize(const QSize& value)
-{
- Q_D(QGLTextureCube);
- if (d->requestedSize == value)
- return;
- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) &&
- !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))
- d->size = QGL::nextPowerOfTwo(value);
- else
- d->size = value;
- d->requestedSize = value;
- ++(d->imageGeneration);
-}
-
-/*!
- Returns the size that was previously set with setSize() before
- it was rounded to a power of two.
-
- \sa size(), setSize()
-*/
-QSize QGLTextureCube::requestedSize() const
-{
- Q_D(const QGLTextureCube);
- return d->requestedSize;
-}
-
-/*!
- Returns the image that is currently associated with the specified
- \a face of this cube map texture. The image may not have been
- uploaded into the GL server yet. Uploads occur upon the next
- call to bind().
-
- \sa setImage()
-*/
-QImage QGLTextureCube::image(QGLTextureCube::Face face) const
-{
- Q_D(const QGLTextureCube);
- if (uint(face) >= 6)
- return QImage();
- if (face == 0)
- return d->image;
- else
- return d->otherImages[face - 1];
-}
-
-/*!
- Sets the \a image that is associated with this texture on the
- specified \a face of the cube map. The image will be uploaded
- into the GL server the next time bind() is called.
-
- If setSize() or setImage() has been called previously, then \a image
- will be scaled to size() when it is uploaded.
-
- If \a image is null, then this function is equivalent to clearImage().
-
- \sa image(), setSize(), copyImage()
-*/
-void QGLTextureCube::setImage
- (QGLTextureCube::Face face, const QImage& image)
-{
- Q_D(QGLTextureCube);
- if (uint(face) >= 6)
- return;
- if (image.isNull()) {
- // Don't change the imageGeneration, because we aren't actually
- // changing the image in the GL server, only the client copy.
- if (face == 0)
- d->image = image;
- else
- d->otherImages[face - 1] = image;
- } else {
- if (!d->size.isValid())
- setSize(image.size());
- if (face == 0)
- d->image = image;
- else
- d->otherImages[face - 1] = image;
- ++(d->imageGeneration);
- d->changedFaces |= (1 << face);
- }
-}
-
-/*!
- Clears the image() that is associated with this texture on the
- specified \a face of the cube map. The GL texture will retain
- its current value. This can be used to release client-side memory
- that is no longer required once the image has been uploaded into
- the GL server.
-
- The following code will queue \c image to be uploaded as the
- positive X face of the cube map, immediately force it to
- be uploaded into the current GL context, and then clear the
- client copy:
-
- \code
- texture.setImage(QGLTextureCube::PositiveX, image);
- texture.bind();
- texture.clearImage(QGLTextureCube::PositiveX);
- \endcode
-
- \sa image(), setImage()
-*/
-void QGLTextureCube::clearImage(QGLTextureCube::Face face)
-{
- Q_D(QGLTextureCube);
- if (face == 0)
- d->image = QImage();
- else
- d->otherImages[face - 1] = QImage();
-}
-
-/*!
- Copies the contents of \a image to \a offset in this texture
- within the current GL context. The \a face parameter indicates
- which face of the cube map should be altered.
-
- Unlike setImage(), this function copies the image data to the
- GL server immediately using \c{glTexSubImage2D()}. This is typically
- used to update the contents of a texture after it has been created.
-
- It is assumed that the application has already called bind() on
- this texture to bind it to the current GL context.
-
- If the texture has been created in multiple contexts, only the
- texture identifier for the current context will be updated.
-
- \sa setImage(), bind()
-*/
-void QGLTextureCube::copyImage
- (QGLTextureCube::Face face, const QImage& image, const QPoint& offset)
-{
- if (uint(face) >= 6)
- return; // Invalid face number.
- QImage img = QGLWidget::convertToGLFormat(image);
- glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + int(face),
- 0, offset.x(), offset.y(),
- img.width(), img.height(), GL_RGBA,
- GL_UNSIGNED_BYTE, img.bits());
-#if defined(QT_OPENGL_ES_2)
- Q_D(QGLTextureCube);
- if (d->bindOptions & QGLContext::MipmapBindOption)
- glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
-#endif
-}
-
-/*!
- Returns the options to use when binding the image() to an OpenGL
- context for the first time. The default options are
- QGLContext::LinearFilteringBindOption |
- QGLContext::InvertedYBindOption | QGLContext::MipmapBindOption.
-
- \sa setBindOptions()
-*/
-QGLContext::BindOptions QGLTextureCube::bindOptions() const
-{
- Q_D(const QGLTextureCube);
- return d->bindOptions;
-}
-
-/*!
- Sets the \a options to use when binding the image() to an
- OpenGL context. If the image() has already been bound,
- then changing the options will cause it to be recreated
- from image() the next time bind() is called.
-
- \sa bindOptions(), bind()
-*/
-void QGLTextureCube::setBindOptions(QGLContext::BindOptions options)
-{
- Q_D(QGLTextureCube);
- if (d->bindOptions != options) {
- d->bindOptions = options;
- ++(d->imageGeneration);
- }
-}
-
-/*!
- Returns the wrapping mode for horizontal texture co-ordinates.
- The default value is QGL::Repeat.
-
- \sa setHorizontalWrap(), verticalWrap()
-*/
-QGL::TextureWrap QGLTextureCube::horizontalWrap() const
-{
- Q_D(const QGLTextureCube);
- return d->horizontalWrap;
-}
-
-/*!
- Sets the wrapping mode for horizontal texture co-ordinates to \a value.
-
- If \a value is not supported by the OpenGL implementation, it will be
- replaced with a value that is supported. If the application desires a
- very specific \a value, it can call horizontalWrap() to check that
- the specific value was actually set.
-
- The \a value will not be applied to the texture in the GL
- server until the next call to bind().
-
- \sa horizontalWrap(), setVerticalWrap()
-*/
-void QGLTextureCube::setHorizontalWrap(QGL::TextureWrap value)
-{
- Q_D(QGLTextureCube);
- value = qt_gl_modify_texture_wrap(value);
- if (d->horizontalWrap != value) {
- d->horizontalWrap = value;
- ++(d->parameterGeneration);
- }
-}
-
-/*!
- Returns the wrapping mode for vertical texture co-ordinates.
- The default value is QGL::Repeat.
-
- \sa setVerticalWrap(), horizontalWrap()
-*/
-QGL::TextureWrap QGLTextureCube::verticalWrap() const
-{
- Q_D(const QGLTextureCube);
- return d->verticalWrap;
-}
-
-/*!
- Sets the wrapping mode for vertical texture co-ordinates to \a value.
-
- If \a value is not supported by the OpenGL implementation, it will be
- replaced with a value that is supported. If the application desires a
- very specific \a value, it can call verticalWrap() to check that
- the specific value was actually set.
-
- The \a value will not be applied to the texture in the GL
- server until the next call to bind().
-
- \sa verticalWrap(), setHorizontalWrap()
-*/
-void QGLTextureCube::setVerticalWrap(QGL::TextureWrap value)
-{
- Q_D(QGLTextureCube);
- value = qt_gl_modify_texture_wrap(value);
- if (d->verticalWrap != value) {
- d->verticalWrap = value;
- ++(d->parameterGeneration);
- }
-}
-
-/*!
- Binds this texture to the cube map texture target.
-
- If this texture object is not associated with an identifier in
- the current context, then a new identifier will be created,
- and the face images will be uploaded into the GL server.
-
- If setImage() or setSize() was called since the last upload,
- then the face images will be re-uploaded to the GL server.
-
- Returns false if the texture could not be bound for some reason.
-
- \sa release(), textureId(), setImage()
-*/
-bool QGLTextureCube::bind() const
-{
- Q_D(const QGLTextureCube);
- return const_cast<QGLTextureCubePrivate *>(d)->bind(GL_TEXTURE_CUBE_MAP);
-}
-
-/*!
- Releases the texture associated with the cube map texture target.
- This is equivalent to \c{glBindTexture(GL_TEXTURE_CUBE_MAP, 0)}.
-
- \sa bind()
-*/
-void QGLTextureCube::release()
-{
- glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
-}
-
-/*!
- Returns the identifier associated with this texture object in
- the current context.
-
- Returns zero if the texture has not previously been bound to
- the 2D texture target in the current context with bind().
-
- \sa bind()
-*/
-GLuint QGLTextureCube::textureId() const
-{
- Q_D(const QGLTextureCube);
- const QGLContext *ctx = QGLContext::currentContext();
- if (!ctx)
- return 0;
- QGLTexture2DTextureInfo *info = d->infos;
- while (info != 0 && info->tex.context() != ctx)
- info = info->next;
- return info ? info->tex.textureId() : 0;
-}
-
-/*!
- Constructs a QGLTextureCube object that wraps the supplied literal
- texture identifier \a id, with the dimensions specified by \a size.
-
- The \a id is assumed to have been created by the application in
- the current GL context, and it will be destroyed by the application
- after the returned QGLTextureCube object is destroyed.
-
- This function is intended for interfacing to existing code that
- uses raw GL texture identifiers. The returned QGLTextureCube can
- only be used with the current GL context.
-
- \sa textureId()
-*/
-QGLTextureCube *QGLTextureCube::fromTextureId(GLuint id, const QSize& size)
-{
- const QGLContext *ctx = QGLContext::currentContext();
- if (!id || !ctx)
- return 0;
-
- QGLTextureCube *texture = new QGLTextureCube();
- if (!size.isNull())
- texture->setSize(size);
- QGLTexture2DTextureInfo *info = new QGLTexture2DTextureInfo
- (ctx, id, texture->d_ptr->imageGeneration,
- texture->d_ptr->parameterGeneration, true);
- texture->d_ptr->infos = info;
- return texture;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/textures/qgltexturecube.h b/src/threed/textures/qgltexturecube.h
deleted file mode 100644
index 24f397b4..00000000
--- a/src/threed/textures/qgltexturecube.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEXTURECUBEMAP_H
-#define QGLTEXTURECUBEMAP_H
-
-#include "qglnamespace.h"
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLTextureCubePrivate;
-
-class Q_QT3D_EXPORT QGLTextureCube
-{
-public:
- QGLTextureCube();
- ~QGLTextureCube();
-
- enum Face
- {
- PositiveX,
- NegativeX,
- PositiveY,
- NegativeY,
- PositiveZ,
- NegativeZ
- };
-
- bool isNull() const;
- bool hasAlphaChannel() const;
-
- QSize size() const;
- void setSize(const QSize& value);
- QSize requestedSize() const;
-
- QImage image(QGLTextureCube::Face face) const;
- void setImage(QGLTextureCube::Face face, const QImage& image);
- void clearImage(QGLTextureCube::Face face);
-
- void copyImage(QGLTextureCube::Face face, const QImage& image, const QPoint& offset = QPoint(0, 0));
-
- QGLContext::BindOptions bindOptions() const;
- void setBindOptions(QGLContext::BindOptions options);
-
- QGL::TextureWrap horizontalWrap() const;
- void setHorizontalWrap(QGL::TextureWrap value);
-
- QGL::TextureWrap verticalWrap() const;
- void setVerticalWrap(QGL::TextureWrap value);
-
- bool bind() const;
- static void release();
-
- GLuint textureId() const;
-
- static QGLTextureCube *fromTextureId(GLuint id, const QSize& size);
-
-private:
- QScopedPointer<QGLTextureCubePrivate> d_ptr;
-
- Q_DISABLE_COPY(QGLTextureCube)
- Q_DECLARE_PRIVATE(QGLTextureCube)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/textures/qgltextureutils.cpp b/src/threed/textures/qgltextureutils.cpp
deleted file mode 100644
index acdf7a9d..00000000
--- a/src/threed/textures/qgltextureutils.cpp
+++ /dev/null
@@ -1,785 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qgltextureutils_p.h"
-#include "qglext_p.h"
-#include <QtCore/qfile.h>
-
-QT_BEGIN_NAMESPACE
-
-QGL::TextureWrap qt_gl_modify_texture_wrap(QGL::TextureWrap value)
-{
- switch (value) {
-#if defined(QT_OPENGL_ES)
- case QGL::Clamp:
- value = QGL::ClampToEdge;
- break;
-#endif
-#if !defined(QT_OPENGL_ES)
- case QGL::ClampToBorder:
- if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_3)
- == 0)
- value = QGL::Clamp;
- break;
-#else
- case QGL::ClampToBorder:
- value = QGL::ClampToEdge;
- break;
-#endif
-#if !defined(QT_OPENGL_ES)
- case QGL::ClampToEdge:
- if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2)
- == 0)
- value = QGL::Clamp;
- break;
-#endif
-#if !defined(QT_OPENGL_ES)
- case QGL::MirroredRepeat:
- if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_4)
- == 0)
- value = QGL::Repeat;
- break;
-#elif !defined(QT_OPENGL_ES_2)
- case QGL::MirroredRepeat:
- value = QGL::Repeat;
- break;
-#endif
- default: break;
- }
- return value;
-}
-
-QGLTextureExtensions::QGLTextureExtensions(const QGLContext *ctx)
- : npotTextures(false)
- , generateMipmap(false)
- , bgraTextureFormat(false)
- , ddsTextureCompression(false)
- , etc1TextureCompression(false)
- , pvrtcTextureCompression(false)
- , compressedTexImage2D(0)
-{
- Q_UNUSED(ctx);
- QGLExtensionChecker extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
- if (extensions.match("GL_ARB_texture_non_power_of_two"))
- npotTextures = true;
- if (extensions.match("GL_SGIS_generate_mipmap"))
- generateMipmap = true;
- if (extensions.match("GL_EXT_bgra"))
- bgraTextureFormat = true;
- if (extensions.match("GL_EXT_texture_compression_s3tc"))
- ddsTextureCompression = true;
- if (extensions.match("GL_OES_compressed_ETC1_RGB8_texture"))
- etc1TextureCompression = true;
- if (extensions.match("GL_IMG_texture_compression_pvrtc"))
- pvrtcTextureCompression = true;
-#if defined(QT_OPENGL_ES_2)
- npotTextures = true;
- generateMipmap = true;
-#endif
-#if !defined(QT_OPENGL_ES)
- if (extensions.match("GL_ARB_texture_compression")) {
- compressedTexImage2D = (q_glCompressedTexImage2DARB)
- ctx->getProcAddress(QLatin1String("glCompressedTexImage2DARB"));
- }
-#else
- compressedTexImage2D = glCompressedTexImage2D;
-#endif
-}
-
-QGLTextureExtensions::~QGLTextureExtensions()
-{
-}
-
-Q_GLOBAL_STATIC(QGLResource<QGLTextureExtensions>, qt_gl_texture_extensions)
-
-QGLTextureExtensions *QGLTextureExtensions::extensions()
-{
- const QGLContext *ctx = QGLContext::currentContext();
- if (!ctx)
- return 0;
- return qt_gl_texture_extensions()->value(ctx);
-}
-
-static void qt_gl_destroyTextureId(GLuint id)
-{
- glDeleteTextures(1, &id);
-}
-
-QGLBoundTexture::QGLBoundTexture()
- : m_resource(qt_gl_destroyTextureId)
- , m_options(QGLContext::DefaultBindOption)
- , m_hasAlpha(false)
-{
-}
-
-QGLBoundTexture::~QGLBoundTexture()
-{
-}
-
-// #define QGL_BIND_TEXTURE_DEBUG
-
-void QGLBoundTexture::startUpload(const QGLContext *ctx, GLenum target, const QSize &imageSize)
-{
- Q_UNUSED(imageSize);
-
- QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
- if (!extensions)
- return;
-
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf("QGLBoundTexture::startUpload(), imageSize=(%d,%d), options=%x\n",
- imageSize.width(), imageSize.height(), int(m_options));
- time.start();
-#endif
-
-#ifndef QT_NO_DEBUG
- // Reset the gl error stack...
- while (glGetError() != GL_NO_ERROR) ;
-#endif
-
- // Create the texture id for the target, which should be one of
- // GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
- GLuint id = m_resource.id();
- if (id) {
- glBindTexture(target, 0); // Just in case texture is bound.
- m_resource.destroy();
- }
- id = 0;
- glGenTextures(1, &id);
- glBindTexture(target, id);
- m_resource.attach(ctx, id);
-
- GLuint filtering = m_options & QGLContext::LinearFilteringBindOption ? GL_LINEAR : GL_NEAREST;
-
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - setting options (%d ms)\n", time.elapsed());
-#endif
- q_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filtering);
-
- if (QGLContext::currentContext()->format().directRendering()
- && extensions->generateMipmap
- && (m_options & QGLContext::MipmapBindOption))
- {
-#if !defined(QT_OPENGL_ES_2)
- glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
- q_glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
-#else
- glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
-#endif
- q_glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
- m_options & QGLContext::LinearFilteringBindOption
- ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST);
- } else {
- q_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filtering);
- m_options &= ~QGLContext::MipmapBindOption;
- }
-}
-
-// map from Qt's ARGB endianness-dependent format to GL's big-endian RGBA layout
-static inline void qt_gl_byteSwapImage(QImage &img, GLenum pixel_type)
-{
- const int width = img.width();
- const int height = img.height();
-
- if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
- || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
- {
- for (int i = 0; i < height; ++i) {
- uint *p = (uint *) img.scanLine(i);
- for (int x = 0; x < width; ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- }
- } else {
- for (int i = 0; i < height; ++i) {
- uint *p = (uint *) img.scanLine(i);
- for (int x = 0; x < width; ++x)
- p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
- }
- }
-}
-
-// #define QGL_BIND_TEXTURE_DEBUG
-
-void QGLBoundTexture::uploadFace
- (GLenum target, const QImage &image, const QSize &scaleSize, GLenum format)
-{
- GLenum internalFormat(format);
-
- // Resolve the texture-related extensions for the current context.
- QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
- if (!extensions)
- return;
-
- // Adjust the image size for scaling and power of two.
- QSize size = (!scaleSize.isEmpty() ? scaleSize : image.size());
- if (!extensions->npotTextures)
- size = QGL::nextPowerOfTwo(size);
- QImage img(image);
- if (size != image.size()) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - scaling up to %dx%d (%d ms) \n", size.width(), size.height(), time.elapsed());
-#endif
- img = img.scaled(size);
- }
- m_size = size;
-
- QImage::Format target_format = img.format();
- bool premul = m_options & QGLContext::PremultipliedAlphaBindOption;
- GLenum externalFormat;
- GLuint pixel_type;
- if (extensions->bgraTextureFormat) {
- externalFormat = GL_BGRA;
- if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2)
- pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- else
- pixel_type = GL_UNSIGNED_BYTE;
- } else {
- externalFormat = GL_RGBA;
- pixel_type = GL_UNSIGNED_BYTE;
- }
-
- switch (target_format) {
- case QImage::Format_ARGB32:
- if (premul) {
- img = img.convertToFormat(target_format = QImage::Format_ARGB32_Premultiplied);
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting ARGB32 -> ARGB32_Premultiplied (%d ms) \n", time.elapsed());
-#endif
- }
- break;
- case QImage::Format_ARGB32_Premultiplied:
- if (!premul) {
- img = img.convertToFormat(target_format = QImage::Format_ARGB32);
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting ARGB32_Premultiplied -> ARGB32 (%d ms)\n", time.elapsed());
-#endif
- }
- break;
- case QImage::Format_RGB16:
- pixel_type = GL_UNSIGNED_SHORT_5_6_5;
- externalFormat = GL_RGB;
- internalFormat = GL_RGB;
- break;
- case QImage::Format_RGB32:
- break;
- default:
- if (img.hasAlphaChannel()) {
- img = img.convertToFormat(premul
- ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_ARGB32);
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting to 32-bit alpha format (%d ms)\n", time.elapsed());
-#endif
- } else {
- img = img.convertToFormat(QImage::Format_RGB32);
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting to 32-bit (%d ms)\n", time.elapsed());
-#endif
- }
- }
-
- if (m_options & QGLContext::InvertedYBindOption) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - flipping bits over y (%d ms)\n", time.elapsed());
-#endif
- if (img.isDetached()) {
- int ipl = img.bytesPerLine() / 4;
- int h = img.height();
- for (int y=0; y<h/2; ++y) {
- int *a = (int *) img.scanLine(y);
- int *b = (int *) img.scanLine(h - y - 1);
- for (int x=0; x<ipl; ++x)
- qSwap(a[x], b[x]);
- }
- } else {
- // Create a new image and copy across. If we use the
- // above in-place code then a full copy of the image is
- // made before the lines are swapped, which processes the
- // data twice. This version should only do it once.
- img = img.mirrored();
- }
- }
-
- if (externalFormat == GL_RGBA) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - doing byte swapping (%d ms)\n", time.elapsed());
-#endif
- // The only case where we end up with a depth different from
- // 32 in the switch above is for the RGB16 case, where we set
- // the format to GL_RGB
- Q_ASSERT(img.depth() == 32);
- qt_gl_byteSwapImage(img, pixel_type);
- }
-#ifdef QT_OPENGL_ES
- // OpenGL/ES requires that the internal and external formats be
- // identical.
- internalFormat = externalFormat;
-#endif
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n",
- img.format(), externalFormat, internalFormat, pixel_type);
-#endif
-
- const QImage &constRef = img; // to avoid detach in bits()...
- glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
- pixel_type, constRef.bits());
-
- m_hasAlpha = (internalFormat != GL_RGB);
-}
-
-void QGLBoundTexture::createFace
- (GLenum target, const QSize &size, GLenum format)
-{
- glTexImage2D(target, 0, format, size.width(),
- size.height(), 0, format, GL_UNSIGNED_BYTE, 0);
- m_hasAlpha = (format != GL_RGB);
-}
-
-void QGLBoundTexture::finishUpload(GLenum target)
-{
- Q_UNUSED(target);
-
-#if defined(QT_OPENGL_ES_2)
- // OpenGL/ES 2.0 needs to generate mipmaps after all cubemap faces
- // have been uploaded.
- if (m_options & QGLContext::MipmapBindOption) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - generating mipmaps (%d ms)\n", time.elapsed());
-#endif
- glGenerateMipmap(target);
- }
-#endif
-
-#ifndef QT_NO_DEBUG
- GLenum error = glGetError();
- if (error != GL_NO_ERROR) {
- qWarning(" - texture upload failed, error code 0x%x, enum: %d (%x)\n", error, target, target);
- }
-#endif
-
-#ifdef QGL_BIND_TEXTURE_DEBUG
- static int totalUploadTime = 0;
- totalUploadTime += time.elapsed();
- printf(" - upload done in (%d ms) time=%d\n", time.elapsed(), totalUploadTime);
-#endif
-}
-
-// DDS format structure
-struct DDSFormat {
- quint32 dwSize;
- quint32 dwFlags;
- quint32 dwHeight;
- quint32 dwWidth;
- quint32 dwLinearSize;
- quint32 dummy1;
- quint32 dwMipMapCount;
- quint32 dummy2[11];
- struct {
- quint32 dummy3[2];
- quint32 dwFourCC;
- quint32 dummy4[5];
- } ddsPixelFormat;
-};
-
-// compressed texture pixel formats
-#define FOURCC_DXT1 0x31545844
-#define FOURCC_DXT2 0x32545844
-#define FOURCC_DXT3 0x33545844
-#define FOURCC_DXT4 0x34545844
-#define FOURCC_DXT5 0x35545844
-
-#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#endif
-
-// PVR header format for container files that store textures compressed
-// with the ETC1, PVRTC2, and PVRTC4 encodings. Format information from the
-// PowerVR SDK at http://www.imgtec.com/powervr/insider/powervr-sdk.asp
-// "PVRTexTool Reference Manual, version 1.11f".
-struct PvrHeader
-{
- quint32 headerSize;
- quint32 height;
- quint32 width;
- quint32 mipMapCount;
- quint32 flags;
- quint32 dataSize;
- quint32 bitsPerPixel;
- quint32 redMask;
- quint32 greenMask;
- quint32 blueMask;
- quint32 alphaMask;
- quint32 magic;
- quint32 surfaceCount;
-};
-
-#define PVR_MAGIC 0x21525650 // "PVR!" in little-endian
-
-#define PVR_FORMAT_MASK 0x000000FF
-#define PVR_FORMAT_PVRTC2 0x00000018
-#define PVR_FORMAT_PVRTC4 0x00000019
-#define PVR_FORMAT_ETC1 0x00000036
-
-#define PVR_HAS_MIPMAPS 0x00000100
-#define PVR_TWIDDLED 0x00000200
-#define PVR_NORMAL_MAP 0x00000400
-#define PVR_BORDER_ADDED 0x00000800
-#define PVR_CUBE_MAP 0x00001000
-#define PVR_FALSE_COLOR_MIPMAPS 0x00002000
-#define PVR_VOLUME_TEXTURE 0x00004000
-#define PVR_ALPHA_IN_TEXTURE 0x00008000
-#define PVR_VERTICAL_FLIP 0x00010000
-
-#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
-#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
-#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
-#endif
-
-#ifndef GL_ETC1_RGB8_OES
-#define GL_ETC1_RGB8_OES 0x8D64
-#endif
-
-bool QGLBoundTexture::canBindCompressedTexture
- (const char *buf, int len, const char *format, bool *hasAlpha,
- bool *isFlipped)
-{
- if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) {
- // Compressed texture loading only supported on little-endian
- // systems such as x86 and ARM at the moment.
- return false;
- }
- if (!format) {
- // Auto-detect the format from the header.
- if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) {
- *hasAlpha = true;
- *isFlipped = true;
- return true;
- } else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) {
- const PvrHeader *pvrHeader =
- reinterpret_cast<const PvrHeader *>(buf);
- *hasAlpha = (pvrHeader->alphaMask != 0);
- *isFlipped = ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0);
- return true;
- }
- } else {
- // Validate the format against the header.
- if (!qstricmp(format, "DDS")) {
- if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) {
- *hasAlpha = true;
- *isFlipped = true;
- return true;
- }
- } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) {
- if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) {
- const PvrHeader *pvrHeader =
- reinterpret_cast<const PvrHeader *>(buf);
- *hasAlpha = (pvrHeader->alphaMask != 0);
- *isFlipped = ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0);
- return true;
- }
- }
- }
- return false;
-}
-
-bool QGLBoundTexture::bindCompressedTexture
- (const char *buf, int len, const char *format)
-{
- if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) {
- // Compressed texture loading only supported on little-endian
- // systems such as x86 and ARM at the moment.
- return false;
- }
-#if !defined(QT_OPENGL_ES)
- QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
- if (!extensions)
- return false;
- if (!extensions->compressedTexImage2D) {
- qWarning("QGLContext::bindTexture(): The GL implementation does "
- "not support texture compression extensions.");
- return false;
- }
-#endif
- if (!format) {
- // Auto-detect the format from the header.
- if (len >= 4 && !qstrncmp(buf, "DDS ", 4))
- return bindCompressedTextureDDS(buf, len);
- else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4))
- return bindCompressedTexturePVR(buf, len);
- } else {
- // Validate the format against the header.
- if (!qstricmp(format, "DDS")) {
- if (len >= 4 && !qstrncmp(buf, "DDS ", 4))
- return bindCompressedTextureDDS(buf, len);
- } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) {
- if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4))
- return bindCompressedTexturePVR(buf, len);
- }
- }
- return false;
-}
-
-bool QGLBoundTexture::bindCompressedTexture
- (const QString& fileName, const char *format)
-{
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly))
- return false;
- QByteArray contents = file.readAll();
- file.close();
- return bindCompressedTexture
- (contents.constData(), contents.size(), format);
-}
-
-bool QGLBoundTexture::bindCompressedTextureDDS(const char *buf, int len)
-{
- QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
- if (!extensions)
- return false;
-
- // Bail out if the necessary extension is not present.
- if (!extensions->ddsTextureCompression) {
- qWarning("QGLBoundTexture::bindCompressedTextureDDS(): DDS texture compression is not supported.");
- return false;
- }
-
- const DDSFormat *ddsHeader = reinterpret_cast<const DDSFormat *>(buf + 4);
- if (!ddsHeader->dwLinearSize) {
- qWarning("QGLBoundTexture::bindCompressedTextureDDS(): DDS image size is not valid.");
- return false;
- }
-
- int blockSize = 16;
- GLenum format;
-
- switch(ddsHeader->ddsPixelFormat.dwFourCC) {
- case FOURCC_DXT1:
- format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- blockSize = 8;
- break;
- case FOURCC_DXT3:
- format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- break;
- case FOURCC_DXT5:
- format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- break;
- default:
- qWarning("QGLBoundTexture::bindCompressedTextureDDS(): DDS image format not supported.");
- return false;
- }
-
- const GLubyte *pixels =
- reinterpret_cast<const GLubyte *>(buf + ddsHeader->dwSize + 4);
-
- GLuint id = m_resource.id();
- if (id) {
- glBindTexture(GL_TEXTURE_2D, 0); // Just in case it is bound.
- m_resource.destroy();
- }
- id = 0;
- glGenTextures(1, &id);
- glBindTexture(GL_TEXTURE_2D, id);
- q_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- q_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- m_resource.attach(QGLContext::currentContext(), id);
-
- int size;
- int offset = 0;
- int available = len - int(ddsHeader->dwSize + 4);
- int w = ddsHeader->dwWidth;
- int h = ddsHeader->dwHeight;
-
- // load mip-maps
- for (int i = 0; i < (int) ddsHeader->dwMipMapCount; ++i) {
- if (w == 0) w = 1;
- if (h == 0) h = 1;
-
- size = ((w+3)/4) * ((h+3)/4) * blockSize;
- if (size > available)
- break;
- extensions->compressedTexImage2D
- (GL_TEXTURE_2D, i, format, w, h, 0, size, pixels + offset);
- offset += size;
- available -= size;
-
- // half size for each mip-map level
- w = w/2;
- h = h/2;
- }
-
- // DDS images are not inverted.
- m_options &= ~QGLContext::InvertedYBindOption;
-
- m_size = QSize(ddsHeader->dwWidth, ddsHeader->dwHeight);
- m_hasAlpha = false;
- return true;
-}
-
-bool QGLBoundTexture::bindCompressedTexturePVR(const char *buf, int len)
-{
- QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
- if (!extensions)
- return false;
-
- // Determine which texture format we will be loading.
- const PvrHeader *pvrHeader = reinterpret_cast<const PvrHeader *>(buf);
- GLenum textureFormat;
- quint32 minWidth, minHeight;
- switch (pvrHeader->flags & PVR_FORMAT_MASK) {
- case PVR_FORMAT_PVRTC2:
- if (pvrHeader->alphaMask)
- textureFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
- else
- textureFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
- minWidth = 16;
- minHeight = 8;
- break;
-
- case PVR_FORMAT_PVRTC4:
- if (pvrHeader->alphaMask)
- textureFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
- else
- textureFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
- minWidth = 8;
- minHeight = 8;
- break;
-
- case PVR_FORMAT_ETC1:
- textureFormat = GL_ETC1_RGB8_OES;
- minWidth = 4;
- minHeight = 4;
- break;
-
- default:
- qWarning("QGLBoundTexture::bindCompressedTexturePVR(): PVR image format 0x%x not supported.", int(pvrHeader->flags & PVR_FORMAT_MASK));
- return false;
- }
-
- // Bail out if the necessary extension is not present.
- if (textureFormat == GL_ETC1_RGB8_OES) {
- if (!extensions->etc1TextureCompression) {
- qWarning("QGLBoundTexture::bindCompressedTexturePVR(): ETC1 texture compression is not supported.");
- return false;
- }
- } else {
- if (!extensions->pvrtcTextureCompression) {
- qWarning("QGLBoundTexture::bindCompressedTexturePVR(): PVRTC texture compression is not supported.");
- return false;
- }
- }
-
- // Boundary check on the buffer size.
- quint32 bufferSize = pvrHeader->headerSize + pvrHeader->dataSize;
- if (bufferSize > quint32(len)) {
- qWarning("QGLBoundTexture::bindCompressedTexturePVR(): PVR image size is not valid.");
- return false;
- }
-
- // Create the texture.
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- GLuint id = m_resource.id();
- if (id) {
- glBindTexture(GL_TEXTURE_2D, 0); // Just in case it is bound.
- m_resource.destroy();
- }
- id = 0;
- glGenTextures(1, &id);
- glBindTexture(GL_TEXTURE_2D, id);
- m_resource.attach(QGLContext::currentContext(), id);
- if (pvrHeader->mipMapCount) {
- if ((m_options & QGLContext::LinearFilteringBindOption) != 0) {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- } else {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
- }
- } else if ((m_options & QGLContext::LinearFilteringBindOption) != 0) {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- } else {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
-
- // Load the compressed mipmap levels.
- const GLubyte *buffer =
- reinterpret_cast<const GLubyte *>(buf + pvrHeader->headerSize);
- bufferSize = pvrHeader->dataSize;
- quint32 level = 0;
- quint32 width = pvrHeader->width;
- quint32 height = pvrHeader->height;
- while (bufferSize > 0 && level <= pvrHeader->mipMapCount) {
- quint32 size =
- (qMax(width, minWidth) * qMax(height, minHeight) *
- pvrHeader->bitsPerPixel) / 8;
- if (size > bufferSize)
- break;
- extensions->compressedTexImage2D
- (GL_TEXTURE_2D, GLint(level), textureFormat,
- GLsizei(width), GLsizei(height), 0, GLsizei(size), buffer);
- width /= 2;
- height /= 2;
- buffer += size;
- ++level;
- }
-
- // Restore the default pixel alignment for later texture uploads.
- glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-
- // Set the invert flag for the texture. The "vertical flip"
- // flag in PVR is the opposite sense to our sense of inversion.
- if ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0)
- m_options &= ~QGLContext::InvertedYBindOption;
- else
- m_options |= QGLContext::InvertedYBindOption;
-
- m_size = QSize(pvrHeader->width, pvrHeader->height);
- m_hasAlpha = (pvrHeader->alphaMask != 0);
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/textures/qgltextureutils_p.h b/src/threed/textures/qgltextureutils_p.h
deleted file mode 100644
index 2cff59d3..00000000
--- a/src/threed/textures/qgltextureutils_p.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLTEXTUREUTILS_P_H
-#define QGLTEXTUREUTILS_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.
-//
-
-#include <QtOpenGL/qgl.h>
-#include <QtCore/qdatetime.h>
-#include "qglnamespace.h"
-#include "qopenglfunctions.h"
-#include "qglsharedresource_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef GL_BGRA
-#define GL_BGRA 0x80E1
-#endif
-#ifndef GL_UNSIGNED_SHORT_5_6_5
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#endif
-#ifndef GL_UNSIGNED_INT_8_8_8_8_REV
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_X
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#endif
-#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#endif
-
-#ifndef GL_GENERATE_MIPMAP_SGIS
-#define GL_GENERATE_MIPMAP_SGIS 0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
-#endif
-
-#if !defined(QT_OPENGL_ES)
-#define q_glTexParameteri(target,name,value) \
- glTexParameteri((target), (name), int(value))
-#else
-#define q_glTexParameteri(target,name,value) \
- glTexParameterf((target), (name), GLfloat(int(value)))
-#endif
-
-// Modify a wrapping mode to account for platform differences.
-QGL::TextureWrap qt_gl_modify_texture_wrap(QGL::TextureWrap value);
-
-typedef void (QT3D_GLF_APIENTRYP q_glCompressedTexImage2DARB)
- (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-
-class QGLTextureExtensions
-{
-public:
- QGLTextureExtensions(const QGLContext *ctx);
- ~QGLTextureExtensions();
-
- int npotTextures : 1;
- int generateMipmap : 1;
- int bgraTextureFormat : 1;
- int ddsTextureCompression : 1;
- int etc1TextureCompression : 1;
- int pvrtcTextureCompression : 1;
- q_glCompressedTexImage2DARB compressedTexImage2D;
-
- static QGLTextureExtensions *extensions();
-};
-
-class QGLBoundTexture
-{
-public:
- QGLBoundTexture();
- ~QGLBoundTexture();
-
- const QGLContext *context() const { return m_resource.context(); }
-
- GLuint textureId() const { return m_resource.id(); }
- void setTextureId(const QGLContext *ctx, GLuint id)
- { m_resource.attach(ctx, id); }
- void clearId() { m_resource.clearId(); }
-
- QGLContext::BindOptions options() const { return m_options; }
- void setOptions(QGLContext::BindOptions options) { m_options = options; }
-
- QSize size() const { return m_size; }
- bool hasAlpha() const { return m_hasAlpha; }
-
- void startUpload(const QGLContext *ctx, GLenum target, const QSize &imageSize);
- void uploadFace(GLenum target, const QImage &image, const QSize &scaleSize,
- GLenum format = GL_RGBA);
- void createFace(GLenum target, const QSize &size, GLenum format = GL_RGBA);
- void finishUpload(GLenum target);
-
- static bool canBindCompressedTexture
- (const char *buf, int len, const char *format, bool *hasAlpha,
- bool *isFlipped);
- bool bindCompressedTexture
- (const QString& fileName, const char *format = 0);
- bool bindCompressedTexture
- (const char *buf, int len, const char *format = 0);
- bool bindCompressedTextureDDS(const char *buf, int len);
- bool bindCompressedTexturePVR(const char *buf, int len);
-
-private:
- QGLSharedResource m_resource;
- QGLContext::BindOptions m_options;
- QSize m_size;
- bool m_hasAlpha;
- QTime time;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/threed/textures/textures.pri b/src/threed/textures/textures.pri
deleted file mode 100644
index ce60c58e..00000000
--- a/src/threed/textures/textures.pri
+++ /dev/null
@@ -1,15 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-HEADERS += \
- textures/qgltexture2d.h \
- textures/qgltexturecube.h \
- textures/qareaallocator.h
-SOURCES += \
- qareaallocator.cpp \
- qglsharedresource.cpp \
- qgltexture2d.cpp \
- qgltexturecube.cpp \
- qgltextureutils.cpp
-PRIVATE_HEADERS += \
- qglsharedresource_p.h \
- qgltexture2d_p.h
diff --git a/src/threed/threed.pri b/src/threed/threed.pri
deleted file mode 100644
index 0c3e68cb..00000000
--- a/src/threed/threed.pri
+++ /dev/null
@@ -1,15 +0,0 @@
-include(global/global.pri)
-include(painting/painting.pri)
-include(arrays/arrays.pri)
-include(effects/effects.pri)
-include(materials/materials.pri)
-include(geometry/geometry.pri)
-include(viewing/viewing.pri)
-include(math3d/math3d.pri)
-include(scene/scene.pri)
-include(network/network.pri)
-include(graphicsview/graphicsview.pri)
-include(textures/textures.pri)
-include(surfaces/surfaces.pri)
-include(api/api.pri)
-
diff --git a/src/threed/threed.pro b/src/threed/threed.pro
deleted file mode 100644
index 9070b38d..00000000
--- a/src/threed/threed.pro
+++ /dev/null
@@ -1,95 +0,0 @@
-TEMPLATE = lib
-TARGET = Qt3D$${QT_LIBINFIX}
-gcov {
- CONFIG += staticlib warn_on
- QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
- QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
-} else {
- CONFIG += dll warn_on
-}
-QT += opengl \
- network
-
-include(../../pkg.pri)
-
-package {
- win32 {
- target.path = $$QT3D_INSTALL_BINS
- } else {
- target.path = $$QT3D_INSTALL_LIBS
- }
- INSTALLS += target
-} else {
- DESTDIR = $$QT3D_INSTALL_LIBS
-}
-
-win32 {
- !static:DEFINES += QT_MAKEDLL
- package {
- installDll.path = $$QT3D_INSTALL_BINS
- installDll.files = $$DESTDIR_TARGET
- INSTALLS += installDll
- } else {
- DLLDESTDIR = $$QT3D_INSTALL_BINS
- }
- CONFIG(debug, debug|release) {
- TARGET = $$member(TARGET, 0)d
- }
-}
-
-symbian {
- DEFINES += QT_MAKEDLL
- CONFIG += epocallowdlldata
- MMP_RULES += EXPORTUNFROZEN
- TARGET.CAPABILITY = All -Tcb
- TARGET.UID3 = 0x20031E95
-}
-
-include(../private/private.pri)
-include(threed.pri)
-PUBLIC_HEADERS = $$HEADERS
-HEADERS += $$PRIVATE_HEADERS
-DEFINES += QT_BUILD_QT3D_LIB
-
-!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
-
-package {
- distInstalls.files = $$PUBLIC_HEADERS
- distInstalls.path = $$QT3D_INSTALL_HEADERS/Qt3D
- INSTALLS += distInstalls
-}
-
-# If Qt has been configured to build frameworks, then the build will put
-# the Qt3D library into a framework bundle, so put the headers in the bundle
-# as well. Other OS's, or mac without frameworks, install the headers into
-# the Qt build tree directly.
-macx:CONFIG(qt_framework, qt_framework|qt_no_framework) {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$DESTDIR/
- CONFIG += lib_bundle
- FRAMEWORK_HEADERS.version = Versions
- FRAMEWORK_HEADERS.path = Headers
- FRAMEWORK_HEADERS.files = $$PUBLIC_HEADERS
- QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
-} else {
- !symbian {
- exportHeaders.input = PUBLIC_HEADERS
- # in the package case we need the headers for the actual build, the
- # distInstalls stanza above takes care of packaging the headers for the dev pkg
- package {
- exportHeaders.output = ../../include/Qt3D/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- } else {
- !maemo: exportHeaders.output = $$[QT_INSTALL_HEADERS]/Qt3D/${QMAKE_FILE_IN_BASE}${QMAKE_FILE_EXT}
- }
- exportHeaders.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- exportHeaders.CONFIG += no_link_no_clean
- exportHeaders.variable_out = PRE_TARGETDEPS
- QMAKE_EXTRA_COMPILERS += exportHeaders
- }
-}
-
-symbian {
- export_headers.files = $$PUBLIC_HEADERS
- for(export_header, export_headers.files) {
- BLD_INF_RULES.prj_exports += "$$export_header $$MW_LAYER_PUBLIC_EXPORT_PATH(Qt3D/$$basename(export_header))"
- }
-}
diff --git a/src/threed/viewing/qglcamera.cpp b/src/threed/viewing/qglcamera.cpp
deleted file mode 100644
index 4f236507..00000000
--- a/src/threed/viewing/qglcamera.cpp
+++ /dev/null
@@ -1,1328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcamera.h"
-#include "qglpainter.h"
-#include <QtGui/qquaternion.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLCamera
- \brief The QGLCamera class defines the projection to apply to simulate a camera's position, orientation, and optics.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::viewing
-
- \section1 Modelview and projection transformations
-
- A QGLCamera instance is applied to the scene in two phases:
- modelview transformation and projection transformation.
-
- During the modelview transformation, the eye(), center(), and
- upVector() are used to generate a 4x4 transformation matrix that
- reflects the viewer's current position and orientation.
-
- During the projection transformation, the projectionType(),
- nearPlane(), farPlane(), fieldOfView(), and viewSize() are used
- to define a viewing volume as a 4x4 transformation matrix.
-
- The modelview transformation matrix is returned by modelViewMatrix().
- The projection transformation matrix is returned by projectionMatrix().
-
- \section1 Positioning and orienting the view
-
- The viewer position and orientation are defined by eye(), center(),
- and upVector(). The location of the viewer in world co-ordinates is
- given by eye(), the viewer is looking at the object of interest located
- at center(), and the upVector() specifies the direction that should
- be considered "up" with respect to the viewer.
-
- The vector from the eye() to the center() is called the "view vector",
- and the cross-product of the view vector and upVector() is called
- the "side vector". The view vector specifies the direction the
- viewer is looking, and the side vector points off to the right of
- the viewer.
-
- It is recommended that the view vector and upVector() be at right angles
- to each other, but this is not required as long as the angle between
- them is close to 90 degrees.
-
- The most common use of view and up vectors that are not at right angles
- is to simulate a human eye at a specific height above the ground looking
- down at a lower object or up at a higher object. In this case, the
- the view vector will not be true horizontal, but the upVector() indicating
- the human's upright stance will be true vertical.
-
- \section1 Zooming the camera image
-
- There are two ways to zoom the image seen through the camera: either
- the camera eye() position can be moved closer to the object of interest,
- or the field of view of the camera lens can be changed to make it appear
- as though the object is moving closer.
-
- Changing the eye() position changes the lighting calculation in the
- scene because the viewer is in a different position, changing the
- angle of light reflection on the object's surface.
-
- The setFieldOfView() function can be used to simulate the effect of a
- camera lens. The smaller the fieldOfView(), the closer the object
- will appear. The lighting calculation will be the same as for the
- unzoomed scene.
-
- If fieldOfView() is zero, then a standard perspective frustum of
- viewSize() is used to define the viewing volume. The viewSize()
- can be adjusted with setViewSize() to zoom the view. A smaller
- viewSize() will make the the object appear closer.
-
- The fieldOfView() or viewSize() is applied as part of the
- projectionMatrix().
-
- \section1 Rotating the viewer or object of interest
-
- Rotating a viewer in 3D space is a very delicate process. It is very
- easy to construct the rotation incorrectly and end up in a "gimbal lock"
- state where further rotations are impossible in certain directions.
-
- To help alleviate this problem, QGLCamera uses a quaternion-based
- approach to generate rotations. A quaternion is a compact representation
- of a rotation in 3D space. Rotations can be combined through quaternion
- multiplication. More information on quaternions can be found in the
- documentation for QQuaternion.
-
- Before rotating the view, you should first decide the type
- of rotation you want to perform:
-
- \list
- \i Tilting or panning a fixed eye to reveal the scene in different
- directions and orientations. This is equivalent to mounting a camera
- on a fixed tripod and then adjusting the direction of view and
- orientation with the tripod controls.
- \i Rotating a moving viewer about the object of interest. This is
- equivalent to moving the viewer around the object at a fixed distance,
- but with the viewer always pointing at the object.
- \endlist
-
- In the QGLCamera class, the first type of rotation is performed with
- rotateEye() and the second with rotateCenter(). Each of these functions
- take a quaternion argument that defines the type of rotation to perform.
-
- The tilt(), pan(), and roll() functions return values that can help with
- constructing the rotation quaternions to pass to rotateEye() and
- rotateCenter(). Tilt and pan are also known as "pitch" and "yaw" in
- flight dynamics.
-
- Three axes of rotation are used to compute the quaternions. The tilt()
- quaternion is computed with respect to the side vector, the pan()
- quaterion is computed with respect to the upVector(), and the roll()
- quaternion is computed with respect to the view vector.
-
- The following example tilts the direction the eye() is pointing
- by 5 degrees, and then pans by 45 degrees:
-
- \code
- camera.rotateEye(camera.tilt(5));
- camera.rotateEye(camera.pan(45));
- \endcode
-
- The next example performs the two rotations in a single fluid step
- (note that the rotation to be performed first is multiplied last):
-
- \code
- camera.rotateEye(camera.pan(45) * camera.tilt(5));
- \endcode
-
- These two examples will not produce the same visual result, even though
- it looks like they might. In the first example, the upVector() is tilted
- before the pan() quaternion is computed. In the second example, the pan()
- quaternion is computed using the original upVector().
-
- This difference in behavior is useful in different situations. Some
- applications may wish to perform all rotations relative to the original
- viewer orientation, and other applications may wish to perform rotations
- relative to the current viewer orientation. These application types
- correspond to the second and first examples above.
-
- \section1 Moving the viewer or object of interest
-
- The simplest way to move the viewer or object of interest is to call
- setEye() or setCenter() respectively and supply a new position in
- world co-ordinates. However, this can lead to non-intuitive movements
- if the viewer orientation is not aligned with the world co-ordinate axes.
-
- For example, subtracting 3 from the eye() x co-ordinate will appear to
- move the eye left 3 units if the viewer orientation is aligned with the
- world co-ordinate axes. But it will not appear to move the eye left 3
- units in any other orientation.
-
- The translation() function can be used to construct a translation
- vector that is aligned with the viewer's current orientation.
- Movement in the x direction will move along the side vector, movement in
- the y direction will move along upVector(), and movement in the z
- direction will move along the view vector.
-
- The translation() function is useful when implementing operations such
- as "step left", "jump up", and so on where the movement should be
- interpreted relative to the viewer's current orientation, not the
- world co-ordinate axes,
-
- In other words, the following two lines of code are not equivalent
- unless the view is oriented with the world co-ordinate axes:
-
- \code
- camera.translateEye(camera.translation(x, y, z));
-
- camera.translateEye(QVector3D(x, y, z));
- \endcode
-
- The following example translates the eye() position while
- keeping the object of interest at the original center():
-
- \code
- camera.translateEye(camera.translation(x, y, z));
- \endcode
-
- The following example translates the object of interest at
- center() while keeping the eye() position fixed:
-
- \code
- camera.translateCenter(camera.translation(x, y, z));
- \endcode
-
- The following example translates both the eye() and the center()
- by the same amount, which will maintain the original view vector.
-
- \code
- QVector3D vector = camera.translation(x, y, z);
- camera.translateEye(vector);
- camera.translateCenter(vector);
- \endcode
-
- It is important that the translation vector for center() be computed
- before eye() is translated if both eye() and center() must move by the
- same amount. The following code translates center() in the viewer
- orientation after the eye() is translated:
-
- \code
- camera.translateEye(camera.translation(x, y, z));
- camera.translateCenter(camera.translation(x, y, z));
- \endcode
-
- Translating both eye() and center() by the same amount can be used
- to simulate sliding a viewer past a scene while always looking in the
- same direction (for example, filming a scene from a moving vehicle).
- An alternative is to fix the viewer and move the scene itself:
- the negation of the translation() vector can be applied to the
- scene's modelview transformation.
-
- \section1 Motion tracking
-
- Viewing of 3D scenes can be enhanced if there is some way to track
- the motion of the viewer or the orientation of the display device.
-
- Applications can use setMotionAdjustment() to alter the position
- of the camera to account for the viewer's motion. This indicates
- the viewer's position relative to the center of the screen.
- The motionAdjustment() vector is used to determine by how much
- the camera position should be adjusted. The distance of the viewer
- from the screen is ignored.
-
- On handheld devices that use accelerometers to determine the
- orientation of the device, the down vector due to gravity
- can be adjusted to serve as a motion tracking vector.
-
- The output of motion tracking hardware can be very noisy,
- with minor fluctuations due to viewer twitch movements or
- environmental factors. The application is responsible for
- cleaning up the signal and removing these fluctuations before
- setMotionAdjustment() is called.
-
- \section1 Stereo projections
-
- QGLCamera can adjust the camera position for rendering separate left
- and right eye images by setting eyeSeparation() to a non-zero value.
- The eyeSeparation() is in world co-ordinates.
-
- Objects that are placed at center() will coincide in the left and
- right eye images, establishing the logical center of the stereo
- effect. Objects that are closer to the eye() will be rendered
- to appear closer in the stereo effect, and objects that are further
- away from eye() than center() will be rendered to appear further away.
-
- Perspective and Orthographic projections incorporate the
- eyeSeparation() into the modelViewMatrix() by altering the
- eye() position.
-
- \sa QGLView, QGLPainter
-*/
-
-/*!
- \qmlclass Camera QGLCamera
- \brief The Camera item defines the viewing position and projection for a 3D scene.
- \since 4.8
- \ingroup qt3d::qml3d
-
- Camera instances are defined on a \l Viewport item using the
- Viewport::camera property:
-
- \code
- import QtQuick 1.0
- import Qt3D 1.0
-
- Viewport {
- width: 640; height: 480
- camera: Camera {
- eye: Qt.vector3d(-1, 2, 10)
- }
- light: Light {}
- Item3D {
- mesh: Mesh { source: "meshes/teapot.bez" }
- effect: Effect {}
- }
- }
- \endcode
-
- \section1 Positioning and orienting the view
-
- The viewer position and orientation are defined by \l eye, \l center,
- and \l upVector. The location of the viewer in world co-ordinates is
- given by \l eye, the viewer is looking at the object of interest located
- at \l center, and the \l upVector specifies the direction that should
- be considered "up" with respect to the viewer.
-
- The vector from the \l eye to the \l center is called the "view vector",
- and the cross-product of the view vector and \l upVector is called
- the "side vector". The view vector specifies the direction the
- viewer is looking, and the side vector points off to the right of
- the viewer.
-
- It is recommended that the view vector and \l upVector be at right angles
- to each other, but this is not required as long as the angle between
- them is close to 90 degrees.
-
- The most common use of view and up vectors that are not at right angles
- is to simulate a human eye at a specific height above the ground looking
- down at a lower object or up at a higher object. In this case, the
- the view vector will not be true horizontal, but the \l upVector
- indicating the human's upright stance will be true vertical.
-
- \section1 Zooming the camera image
-
- There are two ways to zoom the image seen through the camera: either
- the camera \l eye position can be moved closer to the object of interest,
- or the field of view of the camera lens can be changed to make it appear
- as though the object is moving closer.
-
- Changing the \l eye position changes the lighting calculation in the
- scene because the viewer is in a different position, changing the
- angle of light reflection on the object's surface.
-
- The \l fieldOfView property function can be used to simulate the effect
- of a camera lens. The smaller the \l fieldOfView, the closer the object
- will appear. The lighting calculation will be the same as for the
- unzoomed scene.
-
- If \l fieldOfView is zero, then a standard perspective frustum of
- is used to define the viewing volume based on the width and height
- of the \l Viewport.
-
- \section1 Stereo projections
-
- Camera can adjust the camera position for rendering separate left
- and right eye images by setting the \l eyeSeparation property
- to a non-zero value. The \l eyeSeparation is in world co-ordinates.
-
- Objects that are placed at \l center will coincide in the left and
- right eye images, establishing the logical center of the stereo
- effect. Objects that are closer to the \l eye will be rendered
- to appear closer in the stereo effect, and objects that are further
- away from \l eye than \l center will be rendered to appear further away.
-
- \sa Viewport
-*/
-
-class QGLCameraPrivate
-{
-public:
- QGLCameraPrivate();
-
- QGLCamera::ProjectionType projectionType;
- qreal fieldOfView;
- qreal nearPlane;
- qreal farPlane;
- QSizeF viewSize;
- QSizeF minViewSize;
- int screenRotation;
- QVector3D eye;
- QVector3D upVector;
- QVector3D center;
- QVector3D viewVector;
- qreal eyeSeparation;
- QVector3D motionAdjustment;
- QQuaternion motionQuaternion;
- bool adjustForAspectRatio;
-};
-
-QGLCameraPrivate::QGLCameraPrivate()
- : projectionType(QGLCamera::Perspective),
- fieldOfView(0.0f),
- nearPlane(5.0f),
- farPlane(1000.0f),
- viewSize(2.0f, 2.0f),
- minViewSize(0.0001f, 0.0001f),
- screenRotation(0),
- eye(0.0f, 0.0f, 10.0f),
- upVector(0.0f, 1.0f, 0.0f),
- center(0.0f, 0.0f, 0.0f),
- viewVector(0.0f, 0.0f, -10.0f),
- eyeSeparation(0.0f),
- motionAdjustment(0.0f, 0.0f, 1.0f),
- adjustForAspectRatio(true)
-{
-}
-
-/*!
- Constructs a QGLCamera with the default properties and
- attaches it to \a parent.
-*/
-QGLCamera::QGLCamera(QObject *parent)
- : QObject(parent), d_ptr(new QGLCameraPrivate)
-{
-}
-
-/*!
- Destroys this QGLCamera object.
-*/
-QGLCamera::~QGLCamera()
-{
- delete d_ptr;
-}
-
-/*!
- \enum QGLCamera::ProjectionType
- This enum defines the type of view projection to use for a QGLCamera.
-
- \value Perspective Use a perspective view.
- \value Orthographic Use an orthographic view.
-*/
-
-/*!
- \property QGLCamera::projectionType
- \brief the projection type for this camera. The default is Perspective.
-*/
-
-/*!
- \qmlproperty enumeration Camera::projectionType
-
- The projection type for this camera, which is one of:
-
- \list
- \o Perspective Use a perspective view. This is the default.
- \o Orthographic Use an orthographic view.
- \endlist
-*/
-
-QGLCamera::ProjectionType QGLCamera::projectionType() const
-{
- Q_D(const QGLCamera);
- return d->projectionType;
-}
-
-void QGLCamera::setProjectionType(QGLCamera::ProjectionType value)
-{
- Q_D(QGLCamera);
- if (d->projectionType != value) {
- d->projectionType = value;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::fieldOfView
- \brief the field of view in degrees for a perspective projection.
-
- The default value is zero, which indicates a standard perspective
- frustum view volume of viewSize() in size. If the value is not
- zero, then viewSize() is ignored.
-
- This value is ignored if projectionType() is not Perspective.
-
- \sa viewSize()
-*/
-
-/*!
- \qmlproperty real Camera::fieldOfView
- The field of view in degrees for a perspective projection.
-
- The default value is zero, which indicates a standard perspective
- frustum view volume.
-
- This value is ignored if projectionType is not Perspective.
-
- \sa projectionType
-*/
-
-qreal QGLCamera::fieldOfView() const
-{
- Q_D(const QGLCamera);
- return d->fieldOfView;
-}
-
-void QGLCamera::setFieldOfView(qreal angle)
-{
- Q_D(QGLCamera);
- if (d->fieldOfView != angle) {
- d->fieldOfView = angle;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::nearPlane
- \brief the distance from the eye to the near clipping plane.
- The default value is 5.
-
- \sa farPlane()
-*/
-
-/*!
- \qmlproperty real Camera::nearPlane
- The distance from the eye to the near clipping plane.
- The default value is 5.
-
- \sa farPlane
-*/
-
-qreal QGLCamera::nearPlane() const
-{
- Q_D(const QGLCamera);
- return d->nearPlane;
-}
-
-void QGLCamera::setNearPlane(qreal value)
-{
- Q_D(QGLCamera);
- if (d->nearPlane != value) {
- d->nearPlane = value;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::farPlane
- \brief the distance from the eye to the far clipping plane.
- The default value is 1000.
-
- \sa nearPlane()
-*/
-
-/*!
- \qmlproperty real Camera::farPlane
- The distance from the eye to the far clipping plane.
- The default value is 1000.
-
- \sa nearPlane
-*/
-
-qreal QGLCamera::farPlane() const
-{
- Q_D(const QGLCamera);
- return d->farPlane;
-}
-
-void QGLCamera::setFarPlane(qreal value)
-{
- Q_D(QGLCamera);
- if (d->farPlane != value) {
- d->farPlane = value;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::viewSize
- \brief the size of the front of the projection viewing volume.
- The viewing volume is assumed to be centered on the origin.
-
- The default value is (2, 2), which indicates a viewing volume front
- from (-1, -1) to (1, 1).
-
- If the width or height of the viewing volume is negative, then the
- co-ordinates will be swapped. For example, a size of (2, -2) will
- flip the vertical axis upside down for a viewing volume from
- (-1, 1) to (1, -1).
-
- The view size will be further adjusted by the window's aspect ratio
- when projectionMatrix() is called. For best results, the width and
- height of the view size should be the same to define an ideal square
- viewing volume, which is then extended to the final viewing volume
- width and height based on the window's aspect ratio.
-
- \sa projectionMatrix(), minViewSize()
-*/
-QSizeF QGLCamera::viewSize() const
-{
- Q_D(const QGLCamera);
- return d->viewSize;
-}
-
-void QGLCamera::setViewSize(const QSizeF& size)
-{
- Q_D(QGLCamera);
- QSizeF sz(size);
- if (qAbs(sz.width()) < d->minViewSize.width()) {
- if (sz.width() >= 0.0f)
- sz.setWidth(d->minViewSize.width());
- else
- sz.setWidth(-d->minViewSize.width());
- }
- if (qAbs(sz.height()) < d->minViewSize.height()) {
- if (sz.height() >= 0.0f)
- sz.setHeight(d->minViewSize.height());
- else
- sz.setHeight(-d->minViewSize.height());
- }
- if (d->viewSize != sz) {
- d->viewSize = sz;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::minViewSize
- \brief the minimum size of the front of the projection viewing volume.
-
- The minimum view size is used to clamp viewSize() when zooming
- the camera closer to an object to prevent it "passing through"
- the object and causing the scale factor to become infinite.
-
- The default value is (0.0001, 0.0001).
-
- \sa projectionMatrix(), viewSize()
-*/
-QSizeF QGLCamera::minViewSize() const
-{
- Q_D(const QGLCamera);
- return d->minViewSize;
-}
-
-void QGLCamera::setMinViewSize(const QSizeF& size)
-{
- Q_D(QGLCamera);
- if (d->minViewSize != size) {
- d->minViewSize = size;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::screenRotation
- \brief the screen rotation angle in degrees. The default
- value is 0. If this value is 90 or 270, then the view
- will be flipped width for height. The only supported values
- are 0, 90, 180, and 270. The screen is rotated around the
- positive z axis.
-
- This setting is intended for simple screen rotations on handheld
- devices that can be held in either portrait or landscape orientations.
- The entire screen image is rotated so that it can be viewed in a
- different device orientation.
-
- Use rotateEye() or rotateCenter() for more complex rotations
- that are not aligned with 0, 90, 180, or 270 degrees.
-*/
-
-int QGLCamera::screenRotation() const
-{
- Q_D(const QGLCamera);
- return d->screenRotation;
-}
-
-void QGLCamera::setScreenRotation(int angle)
-{
- Q_D(QGLCamera);
- if (d->screenRotation != angle) {
- d->screenRotation = angle;
- emit projectionChanged();
- }
-}
-
-/*!
- \property QGLCamera::eye
- \brief the position of the viewer's eye. The default value is (0, 0, 10).
-
- \sa translateEye(), upVector(), center(), eyeSeparation()
- \sa motionAdjustment()
-*/
-
-/*!
- \qmlproperty vector3D Camera::eye
- The position of the viewer's eye. The default value is (0, 0, 10).
-
- \sa upVector, center, eyeSeparation
-*/
-QVector3D QGLCamera::eye() const
-{
- Q_D(const QGLCamera);
- return d->eye;
-}
-
-void QGLCamera::setEye(const QVector3D& vertex)
-{
- Q_D(QGLCamera);
- if (d->eye != vertex) {
- d->eye = vertex;
- d->viewVector = d->center - d->eye;
- emit viewChanged();
- }
-}
-
-/*!
- Adjusts the position of the viewer's eye by the components
- (\a x, \a y, \a z), where the components are interpreted relative
- to the viewer's current orientation. See translation() for more
- information.
-
- This function is accessible to QML on the Camera item.
-
- \sa eye(), setEye(), translateCenter()
-*/
-void QGLCamera::translateEye(qreal x, qreal y, qreal z)
-{
- Q_D(QGLCamera);
- d->eye += translation(x, y, z);
- d->viewVector = d->center - d->eye;
- emit viewChanged();
-}
-
-/*!
- \property QGLCamera::upVector
- \brief the up vector for the viewer. The default value is (0, 1, 0).
-
- \sa eye(), center()
-*/
-
-/*!
- \qmlproperty vector3D Camera::upVector
- The up vector for the viewer. The default value is (0, 1, 0).
-
- \sa eye, center
-*/
-
-QVector3D QGLCamera::upVector() const
-{
- Q_D(const QGLCamera);
- return d->upVector;
-}
-
-void QGLCamera::setUpVector(const QVector3D& vector)
-{
- Q_D(QGLCamera);
- if (d->upVector != vector) {
- d->upVector = vector;
- emit viewChanged();
- }
-}
-
-/*!
- \property QGLCamera::center
- \brief the center of the view visible from the viewer's position.
- The default value is (0, 0, 0).
-
- \sa translateCenter(), eye(), upVector()
-*/
-
-/*!
- \qmlproperty vector3D Camera::center
- The center of the view visible from the viewer's position.
- The default value is (0, 0, 0).
-
- \sa eye, upVector
-*/
-
-QVector3D QGLCamera::center() const
-{
- Q_D(const QGLCamera);
- return d->center;
-}
-
-void QGLCamera::setCenter(const QVector3D& vertex)
-{
- Q_D(QGLCamera);
- if (d->center != vertex) {
- d->center = vertex;
- d->viewVector = d->center - d->eye;
- emit viewChanged();
- }
-}
-
-/*!
- Adjusts the center of the view by the components (\a x, \a y, \a z),
- where the components are interpreted relative to the viewer's current
- orientation. See translation() for more information.
-
- This function is accessible to QML on the Camera item.
-
- \sa center(), setCenter(), translateEye()
-*/
-void QGLCamera::translateCenter(qreal x, qreal y, qreal z)
-{
- Q_D(QGLCamera);
- d->center += translation(x, y, z);
- d->viewVector = d->center - d->eye;
- emit viewChanged();
-}
-
-/*!
- \property QGLCamera::eyeSeparation
- \brief the separation between the eyes when stereo viewing is in use,
- with eye() specifying the mid-point between the eyes. The default
- value is 0.
-
- \sa eye()
-*/
-
-/*!
- \qmlproperty real Camera::eyeSeparation
- The separation between the eyes when stereo viewing is in use,
- with \l eye property specifying the mid-point between the eyes.
- The default value is 0.
-
- \sa eye
-*/
-
-qreal QGLCamera::eyeSeparation() const
-{
- Q_D(const QGLCamera);
- return d->eyeSeparation;
-}
-
-void QGLCamera::setEyeSeparation(qreal value)
-{
- Q_D(QGLCamera);
- if (d->eyeSeparation != value) {
- d->eyeSeparation = value;
- emit viewChanged();
- }
-}
-
-/*!
- \property QGLCamera::motionAdjustment
- \brief the adjustment vector to apply to the eye() for user motion.
-
- This property is typically used to implement motion tracking.
- It is interpreted as a vector from the center of the screen to the
- current position of the viewer. The angle between the motion
- adjustment vector and the screen center is used to adjust the
- position of the eye() when modelViewMatrix() is called.
-
- The default value is (0, 0, 1), which indicates a viewer
- directly in front of the center of the screen.
-
- The units for the vector are unspecified. They could be
- meters, centimeters, or the force due to gravity in various
- directions from an accelerometer. The angle defined
- by the vector is used to perform the adjustment, not its
- magnitude.
-
- The output of motion tracking hardware can be very noisy,
- with minor fluctuations due to viewer twitch movements or
- environmental factors. The application is responsible for
- cleaning up the signal and removing these fluctuations before
- altering this property.
-
- \sa eye(), modelViewMatrix()
-*/
-
-QVector3D QGLCamera::motionAdjustment() const
-{
- Q_D(const QGLCamera);
- return d->motionAdjustment;
-}
-
-void QGLCamera::setMotionAdjustment(const QVector3D& vector)
-{
- Q_D(QGLCamera);
- if (d->motionAdjustment != vector) {
- d->motionAdjustment = vector;
- if (vector.x() == 0.0f && vector.y() == 0.0f) {
- // If the vector is centered, then don't perform any rotations.
- d->motionQuaternion = QQuaternion();
- } else {
- // Determine the pan and tilt angles from the vector.
- QVector3D view = -vector.normalized();
- if (view.z() < 0.0f)
- view = -view;
- qreal xangle = asin(view.x()) * 180.0f / M_PI;
- qreal yangle = asin(-view.y()) * 180.0f / M_PI;
-
- // Construct the pan and tilt quaternions.
- if (qFuzzyIsNull(xangle))
- d->motionQuaternion = tilt(yangle);
- else if (qFuzzyIsNull(yangle))
- d->motionQuaternion = pan(xangle);
- else
- d->motionQuaternion = tilt(yangle) * pan(xangle);
- }
- emit viewChanged();
- }
-}
-
-/*!
- \property QGLCamera::adjustForAspectRatio
- \brief the adjustment state of the aspect ratio in the viewing volume.
-
- By default, QGLCamera adjusts the viewing volume for the aspect
- ratio of the window so that pixels appear square without the
- application needing to adjust viewSize() manually.
-
- If this property is false, then the aspect ratio adjustment is
- not performed.
-*/
-
-/*!
- \qmlproperty bool Camera::adjustForAspectRatio
- The adjustment state of the aspect ratio in the viewing volume.
-
- By default, the camera adjusts the viewing volume for the aspect
- ratio of the window so that pixels appear square without the
- application needing to adjust the view size manually.
-
- If this property is false, then the aspect ratio adjustment is
- not performed.
-
- \sa projectionType
-*/
-
-bool QGLCamera::adjustForAspectRatio() const
-{
- Q_D(const QGLCamera);
- return d->adjustForAspectRatio;
-}
-
-void QGLCamera::setAdjustForAspectRatio(bool value)
-{
- Q_D(QGLCamera);
- if (d->adjustForAspectRatio != value) {
- d->adjustForAspectRatio = value;
- emit viewChanged();
- }
-}
-
-/*!
- Returns the quaternion corresponding to tilting the view up or
- down by \a angle degrees. The returned quaternion can be applied to
- the eye() position with rotateEye() or to the center() position with
- rotateCenter().
-
- \sa pan(), roll(), rotateEye(), rotateCenter()
-*/
-QQuaternion QGLCamera::tilt(qreal angle) const
-{
- Q_D(const QGLCamera);
- QVector3D side = QVector3D::crossProduct(d->viewVector, d->upVector);
- return QQuaternion::fromAxisAndAngle(side, angle);
-}
-
-/*!
- Returns the quaternion corresponding to panning the view left or
- right by \a angle degrees. The returned quaternion can be applied to
- the eye() position with rotateEye() or to the center() position with
- rotateCenter().
-
- \sa tilt(), roll(), rotateEye(), rotateCenter()
-*/
-QQuaternion QGLCamera::pan(qreal angle) const
-{
- Q_D(const QGLCamera);
- return QQuaternion::fromAxisAndAngle(d->upVector, angle);
-}
-
-/*!
- Returns the quaternion corresponding to rolling the view left or
- right by \a angle degrees. The returned quaternion can be applied to
- the eye() position with rotateEye() or to the center() position with
- rotateCenter().
-
- \sa tilt(), pan(), rotateEye(), rotateCenter()
-*/
-QQuaternion QGLCamera::roll(qreal angle) const
-{
- Q_D(const QGLCamera);
- return QQuaternion::fromAxisAndAngle(d->viewVector, angle);
-}
-
-/*!
- Rotates the orientation of the eye() according to the quaternion \a q.
- The eye() will remain in the same position, but the upVector() and
- center() may be altered by the rotation.
-
- \sa rotateCenter(), tilt(), pan(), roll()
-*/
-void QGLCamera::rotateEye(const QQuaternion& q)
-{
- Q_D(QGLCamera);
- d->upVector = q.rotatedVector(d->upVector);
- d->viewVector = q.rotatedVector(d->viewVector);
- d->center = d->eye + d->viewVector;
- emit viewChanged();
-}
-
-/*!
- Rotates the position and orientation of the eye() around center()
- according to the quaternion \a q. The center() will remain in the
- same position, but the upVector() and eye() may be altered by
- the rotation.
-
- \sa rotateEye(), tilt(), pan(), roll()
-*/
-void QGLCamera::rotateCenter(const QQuaternion& q)
-{
- Q_D(QGLCamera);
- d->upVector = q.rotatedVector(d->upVector);
- d->viewVector = q.rotatedVector(d->viewVector);
- d->eye = d->center - d->viewVector;
- emit viewChanged();
-}
-
-/*!
- Returns a translation vector that can be used to adjust the eye()
- or center() by \a x units side-ways, \a y units up,
- and \a z units forwards.
-
- This function is useful when implementing operations such as
- "step left", "jump up", and so on where the movement should be
- interpreted relative to the viewer's current orientation, not the
- world co-ordinate axes.
-
- The following example moves the eye() 2 units to the right of the
- current eye position while keeping the same center() of interest:
-
- \code
- camera.setEye(camera.eye() + camera.translation(2, 0, 0));
- \endcode
-
- \sa translateEye(), translateCenter()
-*/
-QVector3D QGLCamera::translation(qreal x, qreal y, qreal z) const
-{
- Q_D(const QGLCamera);
- QVector3D vector(0.0f, 0.0f, 0.0f);
- if (x != 0.0f)
- vector += QVector3D::normal(d->viewVector, d->upVector) * x;
- if (y != 0.0f)
- vector += d->upVector.normalized() * y;
- if (z != 0.0f)
- vector += d->viewVector.normalized() * z;
- return vector;
-}
-
-/*!
- Returns the transformation matrix to apply to the projection matrix
- to present the scene as viewed from the camera position.
-
- The \a aspectRatio specifies the aspect ratio of the window the
- camera view is being displayed in. An \a aspectRatio of 1 indicates that
- the window is square. An \a aspectRatio greater than 1 indicates that
- the window is wider than it is high. An \a aspectRatio less than 1
- indicates that the window is higher than it is wide.
-
- \sa modelViewMatrix()
-*/
-QMatrix4x4 QGLCamera::projectionMatrix(qreal aspectRatio) const
-{
- Q_D(const QGLCamera);
- QMatrix4x4 m;
- if (!d->adjustForAspectRatio)
- aspectRatio = 1.0f;
- if (d->screenRotation != 0) {
- m.rotate((qreal)(d->screenRotation), 0.0f, 0.0f, 1.0f);
- if (d->screenRotation == 90 || d->screenRotation == 270) {
- if (aspectRatio != 0.0f)
- aspectRatio = 1.0f / aspectRatio;
- }
- }
- if (d->projectionType == Perspective && d->fieldOfView != 0.0f) {
- m.perspective(d->fieldOfView, aspectRatio,
- d->nearPlane, d->farPlane);
- } else {
- qreal halfWidth = d->viewSize.width() / 2.0f;
- qreal halfHeight = d->viewSize.height() / 2.0f;
- if (aspectRatio > 1.0f) {
- halfWidth *= aspectRatio;
- } else if (aspectRatio > 0.0f && aspectRatio < 1.0f) {
- halfHeight /= aspectRatio;
- }
- if (d->projectionType == Perspective) {
- m.frustum(-halfWidth, halfWidth, -halfHeight, halfHeight,
- d->nearPlane, d->farPlane);
- } else {
- m.ortho(-halfWidth, halfWidth, -halfHeight, halfHeight,
- d->nearPlane, d->farPlane);
- }
- }
- return m;
-}
-
-/*!
- Returns the transformation to apply to the modelview matrix
- to present the scene as viewed from the eye position.
-
- The \a eye parameter is used to adjust the camera's position
- horizontally by half of eyeSeparation() if \a eye is QGL::LeftEye
- or QGL::RightEye.
-
- \sa projectionMatrix()
-*/
-QMatrix4x4 QGLCamera::modelViewMatrix(QGL::Eye eye) const
-{
- Q_D(const QGLCamera);
- QMatrix4x4 m;
- QVector3D adjust;
- if (eye == QGL::LeftEye)
- adjust = translation(-d->eyeSeparation / 2.0f, 0.0f, 0.0f);
- else if (eye == QGL::RightEye)
- adjust = translation(d->eyeSeparation / 2.0f, 0.0f, 0.0f);
- if (d->motionQuaternion.isIdentity()) {
- m.lookAt(d->eye + adjust, d->center, d->upVector);
- } else {
- QVector3D up = d->motionQuaternion.rotatedVector(d->upVector);
- QVector3D view = d->motionQuaternion.rotatedVector(d->viewVector);
- m.lookAt(d->center - view + adjust, d->center, up);
- }
- return m;
-}
-
-/*!
- Maps \a point from viewport co-ordinates to eye co-ordinates.
- The size of the viewport is given by \a viewportSize, and its
- aspect ratio by \a aspectRatio.
-
- The returned vector will have its x and y components set to the
- position of the point on the near plane, and the z component
- set to -nearPlane().
-
- This function is used for converting a mouse event's position
- into eye co-ordinates within the current camera view.
-*/
-QVector3D QGLCamera::mapPoint
- (const QPoint& point, qreal aspectRatio, const QSize& viewportSize) const
-{
- Q_D(const QGLCamera);
-
- // Rotate the co-ordinate system to account for the screen rotation.
- int x = point.x();
- int y = point.y();
- int width = viewportSize.width();
- int height = viewportSize.height();
- if (!d->adjustForAspectRatio)
- aspectRatio = 1.0f;
- if (d->screenRotation == 90) {
- if (aspectRatio != 0.0f)
- aspectRatio = 1.0f / aspectRatio;
- qSwap(x, y);
- qSwap(width, height);
- y = height - 1 - y;
- } else if (d->screenRotation == 180) {
- x = width - 1 - x;
- y = height - 1 - y;
- } else if (d->screenRotation == 270) {
- if (aspectRatio != 0.0f)
- aspectRatio = 1.0f / aspectRatio;
- qSwap(x, y);
- qSwap(width, height);
- }
-
- // Determine the relative distance from the middle of the screen.
- // After this xrel and yrel are typically between -1.0 and +1.0
- // (unless the point was outside the viewport). The yrel is
- // flipped upside down to account for the incoming co-ordinate
- // being left-handed, but the world being right-handed.
- qreal xrel, yrel;
- if (width)
- xrel = (((qreal)(x * 2)) - (qreal)width) / (qreal)width;
- else
- xrel = 0.0f;
- if (height)
- yrel = -(((qreal)(y * 2)) - (qreal)height) / (qreal)height;
- else
- yrel = 0.0f;
-
- // Reverse the projection and return the point in world co-ordinates.
- QMatrix4x4 m = projectionMatrix(aspectRatio);
- QMatrix4x4 invm = m.inverted();
- return invm.map(QVector3D(xrel, yrel, -1.0f));
-}
-
-/*!
- \fn void QGLCamera::projectionChanged()
-
- This signal is emitted when one of projectionType(), fieldOfView(),
- nearPlane(), farPlane(), viewSize(), or screenRotation() changes,
- indicating a modification to the optical properties of the camera
- looking at the scene.
-
- \sa viewChanged()
-*/
-
-/*!
- \fn void QGLCamera::viewChanged()
-
- This signal is emitted when one of eye(), upVector(), or center()
- changes, indicating a modification to the viewer's position or
- orientation.
-
- \sa projectionChanged()
-*/
-
-/*!
- \enum QGLCamera::RotateOrder
- This enum defines the order to perform a tilt, pan, and roll
- of a QGLCamera eye or center.
-
- \value TiltPanRoll Tilt, then pan, then roll.
- \value TiltRollPan Tilt, then roll, then pan.
- \value PanTiltRoll Pan, then tilt, then roll.
- \value PanRollTilt Pan, then roll, then tilt.
- \value RollTiltPan Roll, then tilt, then pan.
- \value RollPanTilt Roll, then pan, then tilt.
-*/
-
-/*!
- Tilts the center() up or down by \a tiltAngle degrees,
- pans the center() left or right by \a panAngle degrees,
- and rolls the center() left or right by \a rollAngle degrees,
- all in a single fluid movement. The \a order parameter
- indicates the order in which to perform the rotations.
-
- This function is accessible to QML on the Camera item.
- It is provided as a convenience for navigation items that
- rotate the center in multiple directions at the same time
- based on mouse movements.
-
- \sa tiltPanRollEye()
-*/
-void QGLCamera::tiltPanRollCenter
- (qreal tiltAngle, qreal panAngle, qreal rollAngle,
- QGLCamera::RotateOrder order)
-{
- switch (order) {
- case QGLCamera::TiltPanRoll:
- rotateCenter(roll(rollAngle) * pan(panAngle) * tilt(tiltAngle));
- break;
- case QGLCamera::TiltRollPan:
- rotateCenter(pan(panAngle) * roll(rollAngle) * tilt(tiltAngle));
- break;
- case QGLCamera::PanTiltRoll:
- rotateCenter(roll(rollAngle) * tilt(tiltAngle) * pan(panAngle));
- break;
- case QGLCamera::PanRollTilt:
- rotateCenter(tilt(tiltAngle) * roll(rollAngle) * pan(panAngle));
- break;
- case QGLCamera::RollTiltPan:
- rotateCenter(pan(panAngle) * tilt(tiltAngle) * roll(rollAngle));
- break;
- case QGLCamera::RollPanTilt:
- rotateCenter(tilt(tiltAngle) * pan(panAngle) * roll(rollAngle));
- break;
- }
-}
-
-/*!
- Tilts the eye() up or down by \a tiltAngle degrees,
- pans the eye() left or right by \a panAngle degrees,
- and rolls the eye() left or right by \a rollAngle degrees,
- all in a single fluid movement. The \a order parameter
- indicates the order in which to perform the rotations.
-
- This function is accessible to QML on the Camera item.
- It is provided as a convenience for navigation items that
- rotate the eye in multiple directions at the same time
- based on mouse movements.
-
- \sa tiltPanRollCenter()
-*/
-void QGLCamera::tiltPanRollEye
- (qreal tiltAngle, qreal panAngle, qreal rollAngle,
- QGLCamera::RotateOrder order)
-{
- switch (order) {
- case QGLCamera::TiltPanRoll:
- rotateEye(roll(rollAngle) * pan(panAngle) * tilt(tiltAngle));
- break;
- case QGLCamera::TiltRollPan:
- rotateEye(pan(panAngle) * roll(rollAngle) * tilt(tiltAngle));
- break;
- case QGLCamera::PanTiltRoll:
- rotateEye(roll(rollAngle) * tilt(tiltAngle) * pan(panAngle));
- break;
- case QGLCamera::PanRollTilt:
- rotateEye(tilt(tiltAngle) * roll(rollAngle) * pan(panAngle));
- break;
- case QGLCamera::RollTiltPan:
- rotateEye(pan(panAngle) * tilt(tiltAngle) * roll(rollAngle));
- break;
- case QGLCamera::RollPanTilt:
- rotateEye(tilt(tiltAngle) * pan(panAngle) * roll(rollAngle));
- break;
- }
-}
-
-QDebug operator<<(QDebug dbg, const QGLCamera &cam)
-{
- dbg << "QGLCamera";
- if (!cam.objectName().isEmpty())
- dbg << cam.objectName();
- dbg << "\n";
- dbg << " projection:" << ( cam.projectionType() == QGLCamera::Perspective ?
- "Perspective" : "Orthographic" );
- dbg << "-- viewsize:" << cam.viewSize().width() << "x" << cam.viewSize().height() << "\n";
- dbg << " near-plane:" << cam.nearPlane() << "-- far-plane:" << cam.farPlane();
- dbg << "-- field-of-view:" << cam.fieldOfView() << "\n";
- dbg << " rotation:" << cam.screenRotation() << " -- motion adjust:" <<
- cam.motionAdjustment() << " -- aspect adjust:" << cam.adjustForAspectRatio() << "\n";
- dbg << " eye:" << cam.eye() << "-- center:" << cam.center();
- dbg << "-- up:" << cam.upVector() << "\n";
- return dbg;
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/viewing/qglcamera.h b/src/threed/viewing/qglcamera.h
deleted file mode 100644
index d943d283..00000000
--- a/src/threed/viewing/qglcamera.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCAMERA_H
-#define QGLCAMERA_H
-
-#include "qt3dglobal.h"
-#include "qglnamespace.h"
-#include <QtCore/qobject.h>
-#include <QtCore/qsize.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qquaternion.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLCameraPrivate;
-class QGLPainter;
-
-class Q_QT3D_EXPORT QGLCamera : public QObject
-{
- Q_OBJECT
- Q_ENUMS(ProjectionType RotateOrder)
- Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionChanged)
- Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY projectionChanged)
- Q_PROPERTY(qreal nearPlane READ nearPlane WRITE setNearPlane NOTIFY projectionChanged)
- Q_PROPERTY(qreal farPlane READ farPlane WRITE setFarPlane NOTIFY projectionChanged)
- Q_PROPERTY(QSizeF viewSize READ viewSize WRITE setViewSize NOTIFY projectionChanged)
- Q_PROPERTY(QSizeF minViewSize READ minViewSize WRITE setMinViewSize NOTIFY projectionChanged SCRIPTABLE false)
- Q_PROPERTY(int screenRotation READ screenRotation WRITE setScreenRotation NOTIFY projectionChanged SCRIPTABLE false)
- Q_PROPERTY(QVector3D eye READ eye WRITE setEye NOTIFY viewChanged)
- Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY viewChanged)
- Q_PROPERTY(QVector3D center READ center WRITE setCenter NOTIFY viewChanged)
- Q_PROPERTY(qreal eyeSeparation READ eyeSeparation WRITE setEyeSeparation NOTIFY viewChanged)
- Q_PROPERTY(QVector3D motionAdjustment READ motionAdjustment WRITE setMotionAdjustment DESIGNABLE false NOTIFY viewChanged SCRIPTABLE false)
- Q_PROPERTY(bool adjustForAspectRatio READ adjustForAspectRatio WRITE setAdjustForAspectRatio NOTIFY viewChanged)
-public:
- explicit QGLCamera(QObject *parent = 0);
- ~QGLCamera();
-
- enum ProjectionType
- {
- Perspective,
- Orthographic
- };
-
- QGLCamera::ProjectionType projectionType() const;
- void setProjectionType(QGLCamera::ProjectionType value);
-
- qreal fieldOfView() const;
- void setFieldOfView(qreal angle);
-
- qreal nearPlane() const;
- void setNearPlane(qreal value);
-
- qreal farPlane() const;
- void setFarPlane(qreal value);
-
- QSizeF viewSize() const;
- void setViewSize(const QSizeF& size);
-
- QSizeF minViewSize() const;
- void setMinViewSize(const QSizeF& size);
-
- int screenRotation() const;
- void setScreenRotation(int angle);
-
- QVector3D eye() const;
- void setEye(const QVector3D& vertex);
-
- QVector3D upVector() const;
- void setUpVector(const QVector3D& vector);
-
- QVector3D center() const;
- void setCenter(const QVector3D& vertex);
-
- qreal eyeSeparation() const;
- void setEyeSeparation(qreal value);
-
- QVector3D motionAdjustment() const;
- void setMotionAdjustment(const QVector3D& vector);
-
- bool adjustForAspectRatio() const;
- void setAdjustForAspectRatio(bool value);
-
- QQuaternion tilt(qreal angle) const;
- QQuaternion pan(qreal angle) const;
- QQuaternion roll(qreal angle) const;
-
- void rotateEye(const QQuaternion& q);
- void rotateCenter(const QQuaternion& q);
-
- QVector3D translation(qreal x, qreal y, qreal z) const;
-
- QMatrix4x4 projectionMatrix(qreal aspectRatio) const;
- QMatrix4x4 modelViewMatrix(QGL::Eye eye = QGL::NoEye) const;
-
- QVector3D mapPoint
- (const QPoint& point, qreal aspectRatio,
- const QSize& viewportSize) const;
-
- enum RotateOrder
- {
- TiltPanRoll,
- TiltRollPan,
- PanTiltRoll,
- PanRollTilt,
- RollTiltPan,
- RollPanTilt
- };
-
-public Q_SLOTS:
- void translateEye(qreal x, qreal y, qreal z);
- void translateCenter(qreal x, qreal y, qreal z);
-
- void tiltPanRollCenter(qreal tiltAngle, qreal panAngle, qreal rollAngle,
- QGLCamera::RotateOrder order = TiltPanRoll);
- void tiltPanRollEye(qreal tiltAngle, qreal panAngle, qreal rollAngle,
- QGLCamera::RotateOrder order = TiltPanRoll);
-
-Q_SIGNALS:
- void projectionChanged();
- void viewChanged();
-
-private:
- QGLCameraPrivate *d_ptr;
-
- QGLCameraPrivate *d_func() const { return d_ptr; }
-
- Q_DISABLE_COPY(QGLCamera)
-};
-
-#ifndef QT_NO_DEBUG_STREAM
-#include <QtCore/qdebug.h>
-Q_QT3D_EXPORT QDebug operator<<(QDebug dbg, const QGLCamera &order);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/viewing/qglcameraanimation.cpp b/src/threed/viewing/qglcameraanimation.cpp
deleted file mode 100644
index 7c19e96e..00000000
--- a/src/threed/viewing/qglcameraanimation.cpp
+++ /dev/null
@@ -1,543 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglcameraanimation.h"
-#include "qglcamera.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLCameraAnimation
- \brief The QGLCameraAnimation class implements smooth animations between two camera positions.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::viewing
-
- QGLCameraAnimation modifies the camera() object to fall on a smooth
- path between startEye(), startUpVector(), startCenter() and
- endEye(), endUpVector(), endCenter. The animation will attempt to
- keep the eye and center at the same relative distance from each other
- throughout the animation, as though one object is flying around another.
-
- \sa QGLCamera
-*/
-
-class QGLCameraAnimationPrivate
-{
-public:
- enum PointOfRotation
- {
- Center,
- CenterDual,
- Eye,
- EyeDual,
- Both
- };
-
- QGLCameraAnimationPrivate()
- : camera(0)
- , startEye(0.0f, 0.0f, 10.f)
- , startUpVector(0.0f, 1.0f, 0.0f)
- , startCenter(0.0f, 0.0f, 0.0f)
- , endEye(0.0f, 0.0f, 10.f)
- , endUpVector(0.0f, 1.0f, 0.0f)
- , endCenter(0.0f, 0.0f, 0.0f)
- , duration(250)
- , dirty(true)
- , pointOfRotation(Both)
- , lengthStart(1.0f)
- , lengthEnd(1.0f)
- {
- }
-
- QGLCamera *camera;
- QVector3D startEye;
- QVector3D startUpVector;
- QVector3D startCenter;
- QVector3D endEye;
- QVector3D endUpVector;
- QVector3D endCenter;
- int duration;
- bool dirty;
- QEasingCurve easingCurve;
-
- // Derived values for use during the animation.
- PointOfRotation pointOfRotation;
- QVector3D upVectorAxis;
- qreal upVectorAngle;
- QVector3D pointAxis;
- qreal pointAngle;
- QVector3D centerTranslate;
- QVector3D eyeTranslate;
- qreal lengthStart;
- qreal lengthEnd;
-
- static void rotateBetween(const QVector3D &start, const QVector3D &end,
- const QVector3D &defaultAxis,
- QVector3D *rotationAxis, qreal *rotationAngle);
- void deriveRotations();
-};
-
-static inline bool fuzzyCompareVectors(const QVector3D &v1, const QVector3D &v2)
-{
- return qAbs(v1.x() - v2.x()) <= 0.00001 &&
- qAbs(v1.y() - v2.y()) <= 0.00001 &&
- qAbs(v1.z() - v2.z()) <= 0.00001;
-}
-
-// Determine how to rotate between the "start" and "end" vectors.
-// We use the cross-product of the two vectors as the axis of rotation
-// or "defaultAxis" if the cross-product is zero (180 degree rotation).
-void QGLCameraAnimationPrivate::rotateBetween
- (const QVector3D &start, const QVector3D &end, const QVector3D &defaultAxis,
- QVector3D *rotationAxis, qreal *rotationAngle)
-{
- QVector3D nstart = start.normalized();
- QVector3D nend = end.normalized();
- if (qFuzzyCompare(nstart, nend)) {
- // Vectors are the same, so no rotation to perform.
- *rotationAxis = QVector3D(0, 1, 0);
- *rotationAngle = 0.0f;
- } else {
- QVector3D axis = QVector3D::crossProduct(nstart, nend);
- if (qFuzzyIsNull(axis.x()) && qFuzzyIsNull(axis.y()) &&
- qFuzzyIsNull(axis.z())) {
- // Vectors are probably at 180 degrees to each other.
- // We can pick either direction; arbitrarily pick anti-clockwise.
- *rotationAxis = defaultAxis;
- *rotationAngle = 180.0f;
- } else {
- // Compute the smallest angle between the two vectors
- // from the cosine of the angle (i.e. the dot product).
- *rotationAxis = axis;
- *rotationAngle =
- qAcos(QVector3D::dotProduct(nstart, nend)) * 180.0f / M_PI;
- }
- }
-}
-
-void QGLCameraAnimationPrivate::deriveRotations()
-{
- // If the center points are the same, rotate the eye around the center.
- // If the eye points are the same, rotate the center around the eye.
- // If both are different, then interpolate along linear vectors.
- if (qFuzzyCompare(startCenter, endCenter)) {
- if (qFuzzyCompare(startEye, endEye)) {
- // Center and eye both stay the same: nothing to do.
- pointOfRotation = Both;
- centerTranslate = QVector3D();
- eyeTranslate = QVector3D();
- } else {
- // Centers are the same, rotate the eye position.
- pointOfRotation = Center;
- rotateBetween(startEye - startCenter, endEye - startCenter,
- startUpVector, &pointAxis, &pointAngle);
- lengthStart = (startEye - startCenter).length();
- lengthEnd = (endEye - startCenter).length();
-
- // Rotate the start up vector to the final position. If it is
- // different than the end up vector, we need to perform the
- // animation in two steps: rotate eye, then rotate up.
- QQuaternion q =
- QQuaternion::fromAxisAndAngle(pointAxis, pointAngle);
- QVector3D up = q.rotatedVector(startUpVector);
- if (!fuzzyCompareVectors(startUpVector, endUpVector) &&
- !fuzzyCompareVectors(up, endUpVector)) {
- pointOfRotation = CenterDual;
- rotateBetween(up, endUpVector, endEye - endCenter,
- &upVectorAxis, &upVectorAngle);
- }
- }
- } else if (qFuzzyCompare(startEye, endEye)) {
- // Eyes are the same, rotate the center position.
- pointOfRotation = Eye;
- rotateBetween(startCenter - startEye, endCenter - startEye,
- startUpVector, &pointAxis, &pointAngle);
- lengthStart = (startCenter - startEye).length();
- lengthEnd = (startCenter - endEye).length();
-
- // Rotate the start up vector to the final position. If it is
- // different than the end up vector, we need to perform the
- // animation in two steps: rotate eye, then rotate up.
- QQuaternion q =
- QQuaternion::fromAxisAndAngle(pointAxis, pointAngle);
- QVector3D up = q.rotatedVector(startUpVector);
- if (!fuzzyCompareVectors(startUpVector, endUpVector) &&
- !fuzzyCompareVectors(up, endUpVector)) {
- pointOfRotation = EyeDual;
- rotateBetween(up, endUpVector, endCenter - endEye,
- &upVectorAxis, &upVectorAngle);
- }
- } else {
- // Both center and eye are changing, so perform a linear translation.
- pointOfRotation = Both;
- centerTranslate = endCenter - startCenter;
- eyeTranslate = endEye - startEye;
- }
-
- // If we are doing a single movement, then determine how to
- // rotate the up vector during the movement.
- if (pointOfRotation != CenterDual) {
- rotateBetween(startUpVector, endUpVector, startCenter - startEye,
- &upVectorAxis, &upVectorAngle);
- }
-}
-
-/*!
- Constructs a new camera animation object and attaches it to \a parent.
-*/
-QGLCameraAnimation::QGLCameraAnimation(QObject *parent)
- : QAbstractAnimation(parent)
- , d_ptr(new QGLCameraAnimationPrivate)
-{
-}
-
-/*!
- Destroys this camera animation object.
-*/
-QGLCameraAnimation::~QGLCameraAnimation()
-{
-}
-
-/*!
- \property QGLCameraAnimation::camera
- \brief the camera that will be animated by this animation object;
- null if the camera has not yet been set.
-*/
-
-QGLCamera *QGLCameraAnimation::camera() const
-{
- Q_D(const QGLCameraAnimation);
- return d->camera;
-}
-
-void QGLCameraAnimation::setCamera(QGLCamera *camera)
-{
- Q_D(QGLCameraAnimation);
- d->camera = camera;
-}
-
-/*!
- \property QGLCameraAnimation::startEye
- \brief the position of the viewer's eye at the start of the animation.
- The default value is (0, 0, 10).
-
- \sa startUpVector(), startCenter(), endEye()
-*/
-
-QVector3D QGLCameraAnimation::startEye() const
-{
- Q_D(const QGLCameraAnimation);
- return d->startEye;
-}
-
-void QGLCameraAnimation::setStartEye(const QVector3D &eye)
-{
- Q_D(QGLCameraAnimation);
- d->startEye = eye;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::startUpVector
- \brief the up vector for the viewer at the start of the animation.
- The default value is (0, 1, 0).
-
- \sa startEye(), startCenter(), endUpVector()
-*/
-
-QVector3D QGLCameraAnimation::startUpVector() const
-{
- Q_D(const QGLCameraAnimation);
- return d->startUpVector;
-}
-
-void QGLCameraAnimation::setStartUpVector(const QVector3D &upVector)
-{
- Q_D(QGLCameraAnimation);
- d->startUpVector = upVector;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::startCenter
- \brief the center of the view visible from the viewer's position
- at the start of the animation. The default value is (0, 0, 0).
-
- \sa startEye(), startUpVector(), endCenter()
-*/
-
-QVector3D QGLCameraAnimation::startCenter() const
-{
- Q_D(const QGLCameraAnimation);
- return d->startCenter;
-}
-
-void QGLCameraAnimation::setStartCenter(const QVector3D &center)
-{
- Q_D(QGLCameraAnimation);
- d->startCenter = center;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::endEye
- \brief the position of the viewer's eye at the end of the animation.
- The default value is (0, 0, 10).
-
- \sa endUpVector(), endCenter(), startEye()
-*/
-
-QVector3D QGLCameraAnimation::endEye() const
-{
- Q_D(const QGLCameraAnimation);
- return d->endEye;
-}
-
-void QGLCameraAnimation::setEndEye(const QVector3D &eye)
-{
- Q_D(QGLCameraAnimation);
- d->endEye = eye;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::endUpVector
- \brief the up vector for the viewer at the end of the animation.
- The default value is (0, 1, 0).
-
- \sa endEye(), endCenter(), startUpVector()
-*/
-
-QVector3D QGLCameraAnimation::endUpVector() const
-{
- Q_D(const QGLCameraAnimation);
- return d->endUpVector;
-}
-
-void QGLCameraAnimation::setEndUpVector(const QVector3D &upVector)
-{
- Q_D(QGLCameraAnimation);
- d->endUpVector = upVector;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::endCenter
- \brief the center of the view visible from the viewer's position
- at the end of the animation. The default value is (0, 0, 0).
-
- \sa endEye(), endUpVector(), startCenter()
-*/
-
-QVector3D QGLCameraAnimation::endCenter() const
-{
- Q_D(const QGLCameraAnimation);
- return d->endCenter;
-}
-
-void QGLCameraAnimation::setEndCenter(const QVector3D &center)
-{
- Q_D(QGLCameraAnimation);
- d->endCenter = center;
- d->dirty = true;
-}
-
-/*!
- \property QGLCameraAnimation::duration
- \brief the duration of the animation in milliseconds. The default
- value is 250 milliseconds.
-
- \sa easingCurve()
-*/
-
-int QGLCameraAnimation::duration() const
-{
- Q_D(const QGLCameraAnimation);
- return d->duration;
-}
-
-void QGLCameraAnimation::setDuration(int duration)
-{
- Q_D(QGLCameraAnimation);
- d->duration = duration;
-}
-
-/*!
- \property QGLCameraAnimation::easingCurve
- \brief the easing curve to use for the animation. The default
- value is a linear easing curve.
-
- \sa duration()
-*/
-
-QEasingCurve QGLCameraAnimation::easingCurve() const
-{
- Q_D(const QGLCameraAnimation);
- return d->easingCurve;
-}
-
-void QGLCameraAnimation::setEasingCurve(const QEasingCurve &easing)
-{
- Q_D(QGLCameraAnimation);
- d->easingCurve = easing;
-}
-
-/*!
- \internal
-*/
-void QGLCameraAnimation::updateCurrentTime(int currentTime)
-{
- Q_D(QGLCameraAnimation);
- if (!d->camera)
- return; // Nothing to do if no camera to modify.
- if (currentTime >= d->duration) {
- d->camera->setEye(d->endEye);
- d->camera->setUpVector(d->endUpVector);
- d->camera->setCenter(d->endCenter);
- } else if (currentTime <= 0) {
- d->camera->setEye(d->startEye);
- d->camera->setUpVector(d->startUpVector);
- d->camera->setCenter(d->startCenter);
- } else {
- // Derive the rotation parameters we need if arguments have changed.
- if (d->dirty) {
- d->dirty = false;
- d->deriveRotations();
- }
-
- // Calculate the progress and modify it with the easing curve.
- qreal progress = d->easingCurve.valueForProgress
- (qreal(currentTime) / qreal(d->duration));
-
- // Calculate the new eye and center locations.
- QVector3D eye = d->startEye;
- QVector3D center = d->startCenter;
- QVector3D upVector = d->startUpVector;
- if (d->pointOfRotation == QGLCameraAnimationPrivate::Center) {
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle * progress);
- eye = q.rotatedVector(eye - d->startCenter);
- if (d->lengthStart != d->lengthEnd) {
- qreal length = (1.0f - progress) * d->lengthStart +
- progress * d->lengthEnd;
- eye = eye.normalized() * length;
- }
- eye += d->startCenter;
- } else if (d->pointOfRotation == QGLCameraAnimationPrivate::CenterDual) {
- if (progress < 0.5f) {
- // First half of the animation - rotate the eye position.
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle * progress * 2.0f);
- eye = q.rotatedVector(eye - d->startCenter);
- if (d->lengthStart != d->lengthEnd) {
- qreal length = (1.0f - progress) * d->lengthStart +
- progress * d->lengthEnd;
- eye = eye.normalized() * length;
- }
- eye += d->startCenter;
- upVector = q.rotatedVector(upVector);
- } else {
- // Second half of the animation - rotate the up vector.
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->upVectorAxis,
- d->upVectorAngle * (progress - 0.5f) * 2.0f) *
- QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle);
- eye = d->endEye;
- upVector = q.rotatedVector(upVector);
- }
- } else if (d->pointOfRotation == QGLCameraAnimationPrivate::Eye) {
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle * progress);
- center = q.rotatedVector(center - d->startEye);
- if (d->lengthStart != d->lengthEnd) {
- qreal length = (1.0f - progress) * d->lengthStart +
- progress * d->lengthEnd;
- center = center.normalized() * length;
- }
- center += d->startEye;
- } else if (d->pointOfRotation == QGLCameraAnimationPrivate::EyeDual) {
- if (progress < 0.5f) {
- // First half of the animation - rotate the center position.
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle * progress * 2.0f);
- center = q.rotatedVector(center - d->startEye);
- if (d->lengthStart != d->lengthEnd) {
- qreal length = (1.0f - progress) * d->lengthStart +
- progress * d->lengthEnd;
- center = center.normalized() * length;
- }
- center += d->startEye;
- upVector = q.rotatedVector(upVector);
- } else {
- // Second half of the animation - rotate the up vector.
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->upVectorAxis,
- d->upVectorAngle * (progress - 0.5f) * 2.0f) *
- QQuaternion::fromAxisAndAngle
- (d->pointAxis, d->pointAngle);
- center = d->endCenter;
- upVector = q.rotatedVector(upVector);
- }
- } else {
- eye += d->eyeTranslate * progress;
- center += d->centerTranslate * progress;
- }
-
- // Calculate the new up vector for single-step animations.
- if (d->pointOfRotation != QGLCameraAnimationPrivate::CenterDual &&
- d->pointOfRotation != QGLCameraAnimationPrivate::EyeDual) {
- if (d->upVectorAngle != 0.0f) {
- QQuaternion q = QQuaternion::fromAxisAndAngle
- (d->upVectorAxis, d->upVectorAngle * progress);
- upVector = q.rotatedVector(upVector);
- }
- }
-
- d->camera->setEye(eye);
- d->camera->setUpVector(upVector);
- d->camera->setCenter(center);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/threed/viewing/qglcameraanimation.h b/src/threed/viewing/qglcameraanimation.h
deleted file mode 100644
index e77e6a61..00000000
--- a/src/threed/viewing/qglcameraanimation.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLCAMERAANIMATION_H
-#define QGLCAMERAANIMATION_H
-
-#include <QtCore/qabstractanimation.h>
-#include <QtCore/qeasingcurve.h>
-#include <QtGui/qvector3d.h>
-#include "qt3dglobal.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLCamera;
-class QGLCameraAnimationPrivate;
-
-class Q_QT3D_EXPORT QGLCameraAnimation : public QAbstractAnimation
-{
- Q_OBJECT
- Q_PROPERTY(QGLCamera *camera READ camera WRITE setCamera)
- Q_PROPERTY(QVector3D startEye READ startEye WRITE setStartEye)
- Q_PROPERTY(QVector3D startUpVector READ startUpVector WRITE setStartUpVector)
- Q_PROPERTY(QVector3D startCenter READ startCenter WRITE setStartCenter)
- Q_PROPERTY(QVector3D endEye READ endEye WRITE setEndEye)
- Q_PROPERTY(QVector3D endUpVector READ endUpVector WRITE setEndUpVector)
- Q_PROPERTY(QVector3D endCenter READ endCenter WRITE setEndCenter)
- Q_PROPERTY(int duration READ duration WRITE setDuration)
- Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
-public:
- explicit QGLCameraAnimation(QObject *parent = 0);
- ~QGLCameraAnimation();
-
- QGLCamera *camera() const;
- void setCamera(QGLCamera *camera);
-
- QVector3D startEye() const;
- void setStartEye(const QVector3D &eye);
-
- QVector3D startUpVector() const;
- void setStartUpVector(const QVector3D &upVector);
-
- QVector3D startCenter() const;
- void setStartCenter(const QVector3D &center);
-
- QVector3D endEye() const;
- void setEndEye(const QVector3D &eye);
-
- QVector3D endUpVector() const;
- void setEndUpVector(const QVector3D &upVector);
-
- QVector3D endCenter() const;
- void setEndCenter(const QVector3D &center);
-
- int duration() const;
- void setDuration(int duration);
-
- QEasingCurve easingCurve() const;
- void setEasingCurve(const QEasingCurve &easing);
-
-protected:
- void updateCurrentTime(int currentTime);
-
-private:
- QScopedPointer<QGLCameraAnimationPrivate> d_ptr;
-
- Q_DISABLE_COPY(QGLCameraAnimation)
- Q_DECLARE_PRIVATE(QGLCameraAnimation)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/viewing/qglview.cpp b/src/threed/viewing/qglview.cpp
deleted file mode 100644
index f22314f1..00000000
--- a/src/threed/viewing/qglview.cpp
+++ /dev/null
@@ -1,1496 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 "qglview.h"
-#include "qglframebufferobject.h"
-#include "qglsubsurface.h"
-#include "qglmaskedsurface_p.h"
-#include "qglwidgetsurface.h"
-#include "qgldrawbuffersurface_p.h"
-#include "qray3d.h"
-#include <QtGui/qevent.h>
-#include <QtCore/qmap.h>
-#include <QtGui/qapplication.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGLView
- \brief The QGLView class extends QGLWidget with support for 3D viewing.
- \since 4.8
- \ingroup qt3d
- \ingroup qt3d::viewing
-
- \section1 Navigating
-
- Navigation in 3D space is possible under keyboard and mouse control.
-
- Holding down the left mouse button and dragging it will rotate the
- camera() position around the object being viewed. Holding down the
- left mouse button and the Shift key pans the view in a plane without
- rotating the viewed object.
-
- Using the mouse wheel, the view can be zoomed in or out. If the
- system does not have a mouse wheel, then holding down the left mouse
- button and the Control key and moving the mouse up and down will
- also zoom in and out.
-
- On the keyboard, the left, right, up, and down keys can also be used
- to shift the camera() position around the object being viewed. Shift
- and Control modify keys the same way they modify the left mouse
- button above. Hitting the Home key will cause the camera position
- to be reset to its original position.
-
- \section1 Stereo viewing support
-
- Note - Stereo viewing is experimental and unsupported.
-
- If the hardware supports stereo buffers, then each time the scene needs
- to be painted, QGLView renders it twice: first from the perspective of
- the left eye, and then from the perspective of the right eye.
- The separation between the eye positions is specified by
- QGLCamera::eyeSeparation(). If the eye separation is zero,
- then stereo viewing is disabled and only a single image will
- be rendered per frame.
-
- Three kinds of stereo viewing are possible: hardware stereo,
- anaglyph stereo, and double image stereo.
-
- Hardware stereo relies upon specialized hardware that can render
- the left and right eye images into separate buffers and then show
- them independently to each eye through the use of polarized glasses
- or similar technology. Hardware stereo is used if the \c{-stereo-hw}
- command-line option is supplied or if the user explicitly requests
- stereo buffers when the QGLView is constructed:
-
- \code
- QGLFormat format(QGLFormat::defaultFormat());
- format.setOption(QGL::StereoBuffers);
- QGLView view(format);
- \endcode
-
- Anaglyph stereo is used when the hardware doesn't have specialized
- stereo buffer support. The left eye image is masked by a red
- filter and the right eye image is masked by a cyan filter. This makes
- the resulting images suitable for viewing with standard red-cyan
- anaglyph glasses.
-
- When using red-cyan anaglyphs, it is recommended that the
- scene use non-primary object colors. Pure primary colors such
- as red, green, and blue will only appear to one of the viewer's
- eyes and will inhibit the 3D effect. Non-primary colors or
- grayscale should be used to get the best effects.
-
- Red-cyan anaglyphs can be disorienting to some viewers. If hardware
- stereo is not available and stereo viewing is not critical to
- the application, then stereo can be disabled by setting
- QGLCamera::eyeSeparation() to zero.
-
- Double image stereo involves drawing the left and right eye
- images in a double-wide or double-high window, with the hardware
- combining the images. Four different configurations are available:
- LeftRight, RightLeft, TopBottom,
- and BottomTop, according to the layout of the eye images.
- Double image stereo is selected by calling setStereoType(). It is
- the responsibility of the application to resize the window to
- twice its normal size to accommodate the images.
-
- Ctrl-Left and Ctrl-Right can be used to make the eye separation
- smaller or larger under keyboard control.
-
- A number of command-line options are available to select the
- stereo mode of the QGLView so that the application does not
- need to select the mode itself:
-
- \table
- \row \o \c{-stereo-hw} \o \l Hardware.
- \row \o \c{-stereo-lr} \o LeftRight.
- \row \o \c{-stereo-rl} \o RightLeft.
- \row \o \c{-stereo-tb} \o TopBottom.
- \row \o \c{-stereo-bt} \o BottomTop.
- \row \o \c{-stereo-stretched-lr} \o StretchedLeftRight.
- \row \o \c{-stereo-stretched-rl} \o StretchedRightLeft.
- \row \o \c{-stereo-stretched-tb} \o StretchedTopBottom.
- \row \o \c{-stereo-stretched-bt} \o StretchedBottomTop.
- \endtable
-
- The option can also be supplied in the \c{Quick3D_OPTIONS} environment
- variable:
-
- \code
- $ Quick3D_OPTIONS="-stereo-lr" ./cubehouse
- \endcode
-
- If the application sets the stereo type with setStereoType(),
- that will be used. Next is the command-line setting, and finally
- the contents of the environment variable.
-*/
-
-/*!
- \enum QGLView::Option
- This enum defines an option for QGLView.
-
- \value ObjectPicking Object picking is enabled. Disabled by default.
- \value ShowPicking Objects are rendered with their pick colors instead
- of their normal colors and materials. This can help debug
- problems with object picking. Disabled by default.
- \value CameraNavigation Camera navigation using the keyboard and mouse
- is enabled. Enabled by default.
- \omitvalue PaintingLog
- \value FOVZoom Enables zooming by changing field of view instead of
- physically moving the camera.
-*/
-
-/*!
- \enum QGLView::StereoType
- This enum defines the type of stereo viewing technology being used by QGLView.
-
- \value Hardware Specialized stereo hardware is being used.
- \value RedCyanAnaglyph Stereo is being simulated for viewing by
- red-cyan anaglyph classes.
- \value LeftRight The view is double-wide with the left eye
- image on the left of the window.
- \value RightLeft The view is double-wide with the left eye
- image on the right of the window.
- \value TopBottom The view is double-high with the left eye
- image on the top of the window.
- \value BottomTop The view is double-high with the left eye
- image on the bottom of the window.
- \value StretchedLeftRight Same as LeftRight, but with the
- left and right eye images stretched to double their width.
- \value StretchedRightLeft Same as RightLeft, but with the
- left and right eye images stretched to double their width.
- \value StretchedTopBottom Same as TopBottom, but with the
- left and right eye images stretched to double their height.
- \value StretchedBottomTop Same as BottomTop, but with the
- left and right eye images stretched to double their height.
-*/
-
-class QGLViewPrivate
-{
-public:
- QGLViewPrivate(QGLView *parent)
- : view(parent), mainSurface(parent)
- {
- options = QGLView::CameraNavigation;
- fbo = 0;
- leftSurface = 0;
- rightSurface = 0;
-
- if (parent->format().stereo())
- stereoType = QGLView::Hardware;
- else
- stereoType = QGLView::RedCyanAnaglyph;
-
- pickBufferForceUpdate = true;
- pickBufferMaybeInvalid = true;
- updateQueued = false;
-
- pressedObject = 0;
- pressedButton = Qt::NoButton;
- enteredObject = 0;
-
- defaultCamera = new QGLCamera(parent);
- camera = defaultCamera;
-
- panning = false;
- startPan = QPoint(-1, -1);
- lastPan = QPoint(-1, -1);
- panModifiers = Qt::NoModifier;
- QObject::connect(defaultCamera, SIGNAL(projectionChanged()),
- parent, SLOT(cameraChanged()));
- QObject::connect(defaultCamera, SIGNAL(viewChanged()),
- parent, SLOT(cameraChanged()));
-
- logTime.start();
- lastFrameTime.start();
- QByteArray env = qgetenv("Quick3D_LOG_EVENTS");
- if (env == "1")
- options |= QGLView::PaintingLog;
- }
- ~QGLViewPrivate()
- {
- delete fbo;
- delete leftSurface;
- delete rightSurface;
- }
-
- QGLView *view;
- QGLView::Options options;
- QGLView::StereoType stereoType;
- QGLFramebufferObject *fbo;
- QGLWidgetSurface mainSurface;
- QGLAbstractSurface *leftSurface;
- QGLAbstractSurface *rightSurface;
- bool pickBufferForceUpdate;
- bool pickBufferMaybeInvalid;
- bool updateQueued;
- QMap<int, QObject *> objects;
- QObject *pressedObject;
- Qt::MouseButton pressedButton;
- QObject *enteredObject;
- QGLCamera *defaultCamera;
- QGLCamera *camera;
- bool panning;
- QPoint startPan;
- QPoint lastPan;
- QVector3D startEye;
- QVector3D startCenter;
- QVector3D startUpVector;
- Qt::KeyboardModifiers panModifiers;
- QTime logTime;
- QTime enterTime;
- QTime lastFrameTime;
-
- inline void logEnter(const char *message);
- inline void logLeave(const char *message);
-
- void processStereoOptions(QGLView *view);
- void processStereoOptions(QGLView *view, const QString &arg);
-
- QGLAbstractSurface *leftEyeSurface(const QSize &size);
- QGLAbstractSurface *rightEyeSurface(const QSize &size);
- QGLAbstractSurface *bothEyesSurface();
-};
-
-inline void QGLViewPrivate::logEnter(const char *message)
-{
- if ((options & QGLView::PaintingLog) == 0)
- return;
- int ms = logTime.elapsed();
- enterTime.start();
- int sinceLast = lastFrameTime.restart();
- qDebug("LOG[%d:%02d:%02d.%03d]: ENTER: %s (%d ms since last enter)",
- ms / 3600000, (ms / 60000) % 60,
- (ms / 1000) % 60, ms % 1000, message, sinceLast);
-}
-
-inline void QGLViewPrivate::logLeave(const char *message)
-{
- if ((options & QGLView::PaintingLog) == 0)
- return;
- int ms = logTime.elapsed();
- int duration = enterTime.elapsed();
- qDebug("LOG[%d:%02d:%02d.%03d]: LEAVE: %s (%d ms elapsed)",
- ms / 3600000, (ms / 60000) % 60,
- (ms / 1000) % 60, ms % 1000, message, duration);
-}
-
-static QString qt_gl_stereo_arg()
-{
- QStringList args = QApplication::arguments();
- foreach (QString arg, args) {
- if (arg.startsWith(QLatin1String("-stereo-")))
- return arg;
- }
- QByteArray options(qgetenv("Quick3D_OPTIONS"));
- args = QString::fromLocal8Bit
- (options.constData(), options.size()).split(QLatin1Char(' '));
- foreach (QString arg, args) {
- if (arg.startsWith(QLatin1String("-stereo-")))
- return arg;
- }
- return QString();
-}
-
-void QGLViewPrivate::processStereoOptions(QGLView *view)
-{
- if (stereoType == QGLView::Hardware)
- return;
- QString arg = qt_gl_stereo_arg();
- if (!arg.isEmpty())
- processStereoOptions(view, arg);
-}
-
-void QGLViewPrivate::processStereoOptions(QGLView *view, const QString &arg)
-{
- // If the command-line contains an option that starts with "-stereo-",
- // then convert it into options that define the size and type of
- // stereo window to use for a top-level QGLView. Possible options:
- //
- // hw - use hardware stereo
- // lr, rl, tb, bt - specify the eye order (default is left-right)
- // stretched - used stretched versions of double wide/high modes.
- //
- QStringList opts = arg.mid(8).split(QLatin1Char('-'));
- QGLView::StereoType stereoType;
- bool stretched = opts.contains(QLatin1String("stretched"));
- if (opts.contains(QLatin1String("rl"))) {
- stereoType = stretched ? QGLView::StretchedRightLeft : QGLView::RightLeft;
- } else if (opts.contains(QLatin1String("tb"))) {
- stereoType = stretched ? QGLView::StretchedTopBottom : QGLView::TopBottom;
- } else if (opts.contains(QLatin1String("bt"))) {
- stereoType = stretched ? QGLView::StretchedBottomTop : QGLView::BottomTop;
- } else {
- stereoType = stretched ? QGLView::StretchedLeftRight : QGLView::LeftRight;
- }
- view->setStereoType(stereoType);
-}
-
-class QGLViewSubsurface : public QGLSubsurface
-{
-public:
- QGLViewSubsurface(QGLAbstractSurface *surface, const QRect &region,
- qreal adjust)
- : QGLSubsurface(surface, region), m_adjust(adjust) {}
-
- qreal aspectRatio() const;
-
-private:
- qreal m_adjust;
-};
-
-qreal QGLViewSubsurface::aspectRatio() const
-{
- return QGLSubsurface::aspectRatio() * m_adjust;
-}
-
-// Returns the surface to use to render the left eye image.
-QGLAbstractSurface *QGLViewPrivate::leftEyeSurface(const QSize &size)
-{
- QRect viewport;
- qreal adjust = 1.0f;
- switch (stereoType) {
- case QGLView::Hardware:
-#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT)
- if (!leftSurface) {
- leftSurface = new QGLDrawBufferSurface
- (&mainSurface,
- view->doubleBuffer() ? GL_BACK_LEFT : GL_FRONT_LEFT);
- }
- return leftSurface;
-#endif
- case QGLView::RedCyanAnaglyph:
- if (!leftSurface) {
- leftSurface = new QGLMaskedSurface
- (&mainSurface,
- QGLMaskedSurface::RedMask | QGLMaskedSurface::AlphaMask);
- }
- return leftSurface;
- case QGLView::LeftRight:
- viewport = QRect(0, 0, size.width() / 2, size.height());
- break;
- case QGLView::RightLeft:
- viewport = QRect(size.width() / 2, 0, size.width() / 2, size.height());
- break;
- case QGLView::TopBottom:
- viewport = QRect(0, 0, size.width(), size.height() / 2);
- break;
- case QGLView::BottomTop:
- viewport = QRect(0, size.height() / 2, size.width(), size.height() / 2);
- break;
- case QGLView::StretchedLeftRight:
- viewport = QRect(0, 0, size.width() / 2, size.height());
- adjust = 2.0f;
- break;
- case QGLView::StretchedRightLeft:
- viewport = QRect(size.width() / 2, 0, size.width() / 2, size.height());
- adjust = 2.0f;
- break;
- case QGLView::StretchedTopBottom:
- viewport = QRect(0, 0, size.width(), size.height() / 2);
- adjust = 0.5f;
- break;
- case QGLView::StretchedBottomTop:
- viewport = QRect(0, size.height() / 2, size.width(), size.height() / 2);
- adjust = 0.5f;
- break;
- }
- if (!leftSurface) {
- if (adjust == 1.0f)
- leftSurface = new QGLSubsurface(&mainSurface, viewport);
- else
- leftSurface = new QGLViewSubsurface(&mainSurface, viewport, adjust);
- } else {
- static_cast<QGLSubsurface *>(leftSurface)->setRegion(viewport);
- }
- return leftSurface;
-}
-
-// Returns the surface to use to render the right eye image.
-QGLAbstractSurface *QGLViewPrivate::rightEyeSurface(const QSize &size)
-{
- QRect viewport;
- qreal adjust = 1.0f;
- switch (stereoType) {
- case QGLView::Hardware:
-#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT)
- if (!rightSurface) {
- rightSurface = new QGLDrawBufferSurface
- (&mainSurface,
- view->doubleBuffer() ? GL_BACK_RIGHT : GL_FRONT_RIGHT);
- }
- return rightSurface;
-#endif
- case QGLView::RedCyanAnaglyph:
- if (!rightSurface) {
- rightSurface = new QGLMaskedSurface
- (&mainSurface,
- QGLMaskedSurface::GreenMask | QGLMaskedSurface::BlueMask);
- }
- return rightSurface;
- case QGLView::LeftRight:
- viewport = QRect(size.width() / 2, 0, size.width() / 2, size.height());
- break;
- case QGLView::RightLeft:
- viewport = QRect(0, 0, size.width() / 2, size.height());
- break;
- case QGLView::TopBottom:
- viewport = QRect(0, size.height() / 2, size.width(), size.height() / 2);
- break;
- case QGLView::BottomTop:
- viewport = QRect(0, 0, size.width(), size.height() / 2);
- break;
- case QGLView::StretchedLeftRight:
- viewport = QRect(size.width() / 2, 0, size.width() / 2, size.height());
- adjust = 2.0f;
- break;
- case QGLView::StretchedRightLeft:
- viewport = QRect(0, 0, size.width() / 2, size.height());
- adjust = 2.0f;
- break;
- case QGLView::StretchedTopBottom:
- viewport = QRect(0, size.height() / 2, size.width(), size.height() / 2);
- adjust = 0.5f;
- break;
- case QGLView::StretchedBottomTop:
- viewport = QRect(0, 0, size.width(), size.height() / 2);
- adjust = 0.5f;
- break;
- }
- if (!rightSurface) {
- if (adjust == 1.0f)
- rightSurface = new QGLSubsurface(&mainSurface, viewport);
- else
- rightSurface = new QGLViewSubsurface(&mainSurface, viewport, adjust);
- } else {
- static_cast<QGLSubsurface *>(rightSurface)->setRegion(viewport);
- }
- return rightSurface;
-}
-
-// Returns a surface that can be used to render a non-stereoscopic
-// image into both eyes at the same time. Returns null if the eyes
-// must be rendered one at a time.
-QGLAbstractSurface *QGLViewPrivate::bothEyesSurface()
-{
- switch (stereoType) {
- case QGLView::Hardware:
-#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT)
- return 0;
-#endif
- case QGLView::RedCyanAnaglyph:
- return &mainSurface;
- default:
- return 0;
- }
-}
-
-static QGLFormat makeStereoGLFormat(const QGLFormat& format)
-{
-#if defined(GL_BACK_LEFT) && defined(GL_BACK_RIGHT)
- QGLFormat fmt(format);
- if (qt_gl_stereo_arg() == QLatin1String("-stereo-hw"))
- fmt.setOption(QGL::StereoBuffers);
- return fmt;
-#else
- QGLFormat fmt(format);
- fmt.setOption(QGL::NoStereoBuffers);
- return fmt;
-#endif
-}
-
-/*!
- Constructs a new view widget and attaches it to \a parent.
-
- This constructor will request a stereo rendering context if
- the hardware supports it.
-*/
-QGLView::QGLView(QWidget *parent)
- : QGLWidget(makeStereoGLFormat(QGLFormat::defaultFormat()), parent)
-{
- d = new QGLViewPrivate(this);
- setMouseTracking(true);
- if (!parent)
- d->processStereoOptions(this);
-}
-
-/*!
- Constructs a new view widget and attaches it to \a parent.
- The \a format argument specifies the desired QGLFormat
- rendering options.
-
- If \a format does not include the stereo option, then a stereo
- viewing context will not be requested.
-*/
-QGLView::QGLView(const QGLFormat& format, QWidget *parent)
- : QGLWidget(format, parent)
-{
- d = new QGLViewPrivate(this);
- setMouseTracking(true);
- if (!parent)
- d->processStereoOptions(this);
-}
-
-/*!
- Destroys this view widget.
-*/
-QGLView::~QGLView()
-{
- delete d;
-}
-
-/*!
- Returns the options for this view. The default value is
- CameraNavigation.
-
- \sa setOptions(), setOption()
-*/
-QGLView::Options QGLView::options() const
-{
- return d->options;
-}
-
-/*!
- Sets the options for this view to \a value.
-
- \sa options(), setOption()
-*/
-void QGLView::setOptions(QGLView::Options value)
-{
- d->options = value;
-}
-
-/*!
- Enables or disables \a option according to \a value.
-
- \sa options(), setOptions()
-*/
-void QGLView::setOption(QGLView::Option option, bool value)
-{
- if (value)
- d->options |= option;
- else
- d->options &= ~option;
-}
-
-/*!
- Returns the type of stereo viewing technology that is in use.
-
- \sa setStereoType()
-*/
-QGLView::StereoType QGLView::stereoType() const
-{
- return d->stereoType;
-}
-
-/*!
- Sets the \a type of stereo viewing technology that is in use.
- The request takes effect at the next repaint.
-
- The request is ignored stereoType() or \a type is Hardware,
- because hardware stereo can only be enabled if the hardware
- supports it, and then it can never be disabled.
-
- \sa stereoType()
-*/
-void QGLView::setStereoType(QGLView::StereoType type)
-{
- if (d->stereoType == Hardware || type == Hardware)
- return;
- if (d->stereoType == type)
- return;
- d->stereoType = type;
-
- // Destroy the current surface objects so that they will
- // be re-generated the next time we paint the widget.
- delete d->leftSurface;
- delete d->rightSurface;
- d->leftSurface = 0;
- d->rightSurface = 0;
-}
-
-/*!
- Registers an \a object with this view to be notified when
- \a objectId is selected with the mouse. The \a object must
- persist for the lifetime of the QGLView, or until
- deregisterObject() is called for \a objectId.
-
- \sa deregisterObject(), objectForPoint()
-*/
-void QGLView::registerObject(int objectId, QObject *object)
-{
- d->objects[objectId] = object;
-}
-
-/*!
- Deregisters the object associated with \a objectId.
-
- \sa registerObject()
-*/
-void QGLView::deregisterObject(int objectId)
-{
- d->objects.remove(objectId);
-}
-
-/*!
- Returns the camera parameters. The camera defines the projection
- to apply to convert eye co-ordinates into window co-ordinates,
- and the position and orientation of the viewer's eye.
-
- \sa setCamera()
-*/
-QGLCamera *QGLView::camera() const
-{
- return d->camera;
-}
-
-/*!
- Sets the camera parameters to \a value. The camera defines the
- projection to apply to convert eye co-ordinates into window
- co-ordinates, and the position and orientation of the viewer's eye.
-
- If \a value is null, then the default camera object will be used.
-
- This function will call update() to force the view to
- update with the new camera parameters upon the next event loop.
-
- \sa camera()
-*/
-void QGLView::setCamera(QGLCamera *value)
-{
- if (!value)
- value = d->defaultCamera;
-
- if (d->camera == value)
- return;
-
- disconnect(d->camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- disconnect(d->camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
-
- d->camera = value;
-
- connect(d->camera, SIGNAL(projectionChanged()),
- this, SLOT(cameraChanged()));
- connect(d->camera, SIGNAL(viewChanged()),
- this, SLOT(cameraChanged()));
-
- cameraChanged();
-}
-
-/*!
- Maps \a point from viewport co-ordinates to eye co-ordinates.
-
- The returned vector will have its x and y components set to the
- position of the point on the near plane, and the z component
- set to the inverse of the camera's near plane.
-
- This function is used for converting a mouse event's position
- into eye co-ordinates within the current camera view.
-
- \sa QGLCamera::mapPoint()
-*/
-QVector3D QGLView::mapPoint(const QPoint &point) const
-{
- QSize viewportSize(size());
- qreal aspectRatio;
-
- // Get the size of the underlying paint device.
- int width = viewportSize.width();
- int height = viewportSize.height();
-
- // Use the device's DPI setting to determine the pixel aspect ratio.
- int dpiX = logicalDpiX();
- int dpiY = logicalDpiY();
- if (dpiX <= 0 || dpiY <= 0)
- dpiX = dpiY = 1;
-
- // Derive the aspect ratio based on window and pixel size.
- if (width <= 0 || height <= 0)
- aspectRatio = 1.0f;
- else
- aspectRatio = ((qreal)(width * dpiY)) / ((qreal)(height * dpiX));
-
- // Map the point into eye co-ordinates.
- return d->camera->mapPoint(point, aspectRatio, viewportSize);
-}
-
-void QGLView::cameraChanged()
-{
- // The pick buffer will need to be refreshed at the new camera position.
- d->pickBufferForceUpdate = true;
-
- // Queue an update for the next event loop.
- update();
-}
-
-/*!
- \internal
-*/
-void QGLView::initializeGL()
-{
- d->logEnter("QGLView::initializeGL");
- QGLPainter painter;
- painter.begin();
-
- // Set the default depth buffer options.
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glDepthMask(GL_TRUE);
-#if defined(QT_OPENGL_ES)
- glDepthRangef(0.0f, 1.0f);
-#else
- glDepthRange(0.0f, 1.0f);
-#endif
-
- // Set the default blend options.
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter.glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter.glBlendEquation(GL_FUNC_ADD);
- else if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
-
- glDisable(GL_CULL_FACE);
- initializeGL(&painter);
- d->logLeave("QGLView::initializeGL");
-}
-
-/*!
- \internal
-*/
-void QGLView::resizeGL(int w, int h)
-{
- // Set up the standard viewport for the new window size.
- glViewport(0, 0, w, h);
-
- // We will need to regenerate the pick buffer.
- d->pickBufferForceUpdate = true;
-}
-
-/*!
- \internal
-*/
-void QGLView::paintGL()
-{
- d->logEnter("QGLView::paintGL");
- // We may need to regenerate the pick buffer on the next mouse event.
- d->pickBufferMaybeInvalid = true;
-
- // Paint the scene contents.
- QGLPainter painter;
- QGLAbstractSurface *surface;
- painter.begin();
- if (d->options & QGLView::ShowPicking &&
- d->stereoType == QGLView::RedCyanAnaglyph) {
- // If showing picking, then render normally. This really
- // only works if we aren't using hardware or double stereo.
- painter.setPicking(true);
- painter.clearPickObjects();
- painter.setEye(QGL::NoEye);
- earlyPaintGL(&painter);
- painter.setCamera(d->camera);
- paintGL(&painter);
- painter.setPicking(false);
- } else if (d->camera->eyeSeparation() == 0.0f &&
- (surface = d->bothEyesSurface()) != 0) {
- // No camera separation, so render the same image into both buffers.
- painter.pushSurface(surface);
- painter.setEye(QGL::NoEye);
- earlyPaintGL(&painter);
- painter.setCamera(d->camera);
- paintGL(&painter);
- painter.popSurface();
- } else {
- // Paint the scene twice, from the perspective of each camera.
- QSize size(this->size());
- painter.setEye(QGL::LeftEye);
- if (d->stereoType != QGLView::Hardware)
- earlyPaintGL(&painter); // Clear both eyes at the same time.
- painter.pushSurface(d->leftEyeSurface(size));
- if (d->stereoType == QGLView::Hardware)
- earlyPaintGL(&painter); // Clear the left eye only.
- earlyPaintGL(&painter);
- painter.setCamera(d->camera);
- paintGL(&painter);
- if (d->stereoType == QGLView::RedCyanAnaglyph)
- glClear(GL_DEPTH_BUFFER_BIT);
- painter.setEye(QGL::RightEye);
- painter.setSurface(d->rightEyeSurface(size));
- if (d->stereoType == QGLView::Hardware)
- earlyPaintGL(&painter); // Clear the right eye only.
- painter.setCamera(d->camera);
- paintGL(&painter);
- painter.popSurface();
- }
- d->logLeave("QGLView::paintGL");
-}
-
-/*!
- Initializes the current GL context represented by \a painter.
-
- \sa paintGL()
-*/
-void QGLView::initializeGL(QGLPainter *painter)
-{
- Q_UNUSED(painter);
-}
-
-/*!
- Performs early painting operations just after \a painter
- is initialized but before the camera is set up. The default
- implementation clears the color buffer and depth buffer.
-
- This function is typically overridden to draw scene backdrops
- on the color buffer before the rest of the scene is drawn
- by paintGL().
-
- \sa paintGL()
-*/
-void QGLView::earlyPaintGL(QGLPainter *painter)
-{
- Q_UNUSED(painter);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-}
-
-/*!
- \fn void QGLView::paintGL(QGLPainter *painter)
-
- Paints the scene onto \a painter. The color and depth buffers
- will have already been cleared, and the camera() position set.
-
- If QGLPainter::isPicking() is set for \a painter, then the
- function should paint the scene onto \a painter in
- "object picking mode". The scene will be rendered into a
- background buffer using flat colors so that mouse events
- can determine which object lies under the mouse pointer.
-
- The default implementation of picking will typically just
- render the scene normally. However, some applications
- may wish to render a simpler scene that omits unselectable
- objects and uses simpler meshes for the selectable objects.
-
- \sa earlyPaintGL()
-*/
-
-/*!
- Processes the mouse press event \a e.
-*/
-void QGLView::mousePressEvent(QMouseEvent *e)
-{
- QObject *object;
- if (!d->panning && (d->options & QGLView::ObjectPicking) != 0)
- object = objectForPoint(e->pos());
- else
- object = 0;
- if (d->pressedObject) {
- // Send the press event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonPress,
- (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(d->pressedObject, &event);
- } else if (object) {
- // Record the object that was pressed and forward the event.
- d->pressedObject = object;
- d->enteredObject = 0;
- d->pressedButton = e->button();
-
- // Send a mouse press event for (0, 0).
- QMouseEvent event(QEvent::MouseButtonPress, QPoint(0, 0),
- e->globalPos(), e->button(), e->buttons(),
- e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- } else if ((d->options & QGLView::CameraNavigation) != 0 &&
- e->button() == Qt::LeftButton) {
- d->panning = true;
- d->lastPan = d->startPan = e->pos();
- d->startEye = d->camera->eye();
- d->startCenter = d->camera->center();
- d->startUpVector = d->camera->upVector();
- d->panModifiers = e->modifiers();
-#ifndef QT_NO_CURSOR
- setCursor(Qt::ClosedHandCursor);
-#endif
- }
- QGLWidget::mousePressEvent(e);
-}
-
-/*!
- Processes the mouse release event \a e.
-*/
-void QGLView::mouseReleaseEvent(QMouseEvent *e)
-{
- if (d->panning && e->button() == Qt::LeftButton) {
- d->panning = false;
-#ifndef QT_NO_CURSOR
- unsetCursor();
-#endif
- }
- if (d->pressedObject) {
- // Notify the previously pressed object about the release.
- QObject *object = objectForPoint(e->pos());
- QObject *pressed = d->pressedObject;
- if (e->button() == d->pressedButton) {
- d->pressedObject = 0;
- d->pressedButton = Qt::NoButton;
- d->enteredObject = object;
-
- // Send the release event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonRelease,
- (pressed == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(pressed, &event);
-
- // Send leave and enter events if necessary.
- if (object != pressed) {
- sendLeaveEvent(pressed);
- if (object)
- sendEnterEvent(object);
- }
- } else {
- // Some other button than the original was released.
- // Forward the event to the pressed object.
- QMouseEvent event
- (QEvent::MouseButtonRelease,
- (pressed == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(pressed, &event);
- }
- }
- QGLWidget::mouseReleaseEvent(e);
-}
-
-/*!
- Processes the mouse double click event \a e.
-*/
-void QGLView::mouseDoubleClickEvent(QMouseEvent *e)
-{
- if ((d->options & QGLView::ObjectPicking) != 0) {
- QObject *object = objectForPoint(e->pos());
- if (object) {
- // Simulate a double click event for (0, 0).
- QMouseEvent event
- (QEvent::MouseButtonDblClick, QPoint(0, 0),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- }
- }
- QGLWidget::mouseDoubleClickEvent(e);
-}
-
-/*!
- Processes the mouse move event \a e.
-*/
-void QGLView::mouseMoveEvent(QMouseEvent *e)
-{
- if (d->panning) {
- QPoint delta = e->pos() - d->startPan;
- if (e->modifiers() == d->panModifiers) {
- d->camera->setEye(d->startEye);
- d->camera->setCenter(d->startCenter);
- d->camera->setUpVector(d->startUpVector);
- } else {
- d->startPan = d->lastPan;
- delta = e->pos() - d->startPan;
- d->startEye = d->camera->eye();
- d->startCenter = d->camera->center();
- d->startUpVector = d->camera->upVector();
- d->panModifiers = e->modifiers();
- }
- d->lastPan = e->pos();
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(delta.y() * -60);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(delta.x(), delta.y());
- else
- rotate(delta.x(), delta.y());
- } else if ((d->options & QGLView::ObjectPicking) != 0) {
- QObject *object = objectForPoint(e->pos());
- if (d->pressedObject) {
- // Send the move event to the pressed object. Use a position
- // of (0, 0) if the mouse is still within the pressed object,
- // or (-1, -1) if the mouse is no longer within the pressed object.
- QMouseEvent event
- (QEvent::MouseMove,
- (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(d->pressedObject, &event);
- } else if (object) {
- if (object != d->enteredObject) {
- if (d->enteredObject)
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = object;
- sendEnterEvent(d->enteredObject);
- }
- QMouseEvent event
- (QEvent::MouseMove, QPoint(0, 0),
- e->globalPos(), e->button(), e->buttons(), e->modifiers());
- QCoreApplication::sendEvent(object, &event);
- } else if (d->enteredObject) {
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = 0;
- }
- }
- QGLWidget::mouseMoveEvent(e);
-}
-
-/*!
- Processes the leave event \a e.
-*/
-void QGLView::leaveEvent(QEvent *e)
-{
- if (!d->pressedObject && d->enteredObject) {
- sendLeaveEvent(d->enteredObject);
- d->enteredObject = 0;
- }
- QGLWidget::leaveEvent(e);
-}
-
-#ifndef QT_NO_WHEELEVENT
-
-/*!
- Processes the wheel event \a e.
-*/
-void QGLView::wheelEvent(QWheelEvent *e)
-{
- if ((d->options & QGLView::CameraNavigation) != 0)
- wheel(e->delta());
- QGLWidget::wheelEvent(e);
-}
-
-#endif
-
-/*!
- Processes the key press event \a e.
-*/
-void QGLView::keyPressEvent(QKeyEvent *e)
-{
- QGLCamera *camera;
- qreal sep;
-
- if ((d->options & QGLView::CameraNavigation) == 0) {
- QGLWidget::keyPressEvent(e);
- return;
- }
- switch (e->key()) {
-
- case Qt::Key_Escape:
- case Qt::Key_Q:
- {
- if (parentWidget() == 0)
- close();
- }
-
- case Qt::Key_Left:
- {
- if ((e->modifiers() & Qt::ShiftModifier) != 0) {
- pan(-10, 0);
- } else if ((e->modifiers() & Qt::ControlModifier) != 0) {
- camera = this->camera();
- sep = camera->eyeSeparation();
- sep -= (sep / 10.0f);
- if (sep < 0.0f)
- sep = 0.0f;
- camera->setEyeSeparation(sep);
- e->accept();
- return;
- } else {
- rotate(-10, 0);
- }
- }
- break;
-
- case Qt::Key_Right:
- {
- if ((e->modifiers() & Qt::ShiftModifier) != 0) {
- pan(10, 0);
- } else if ((e->modifiers() & Qt::ControlModifier) != 0) {
- camera = this->camera();
- sep = camera->eyeSeparation();
- sep += (sep / 10.0f);
- camera->setEyeSeparation(sep);
- e->accept();
- return;
- } else {
- rotate(10, 0);
- }
- }
- break;
-
- case Qt::Key_Up:
- {
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(120);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(0, -10);
- else
- rotate(0, -10);
- }
- break;
-
- case Qt::Key_Down:
- {
- if ((e->modifiers() & Qt::ControlModifier) != 0)
- wheel(-120);
- else if ((e->modifiers() & Qt::ShiftModifier) != 0)
- pan(0, 10);
- else
- rotate(0, 10);
- }
- break;
- }
- QGLWidget::keyPressEvent(e);
-}
-
-class QGLViewPickSurface : public QGLAbstractSurface
-{
-public:
- QGLViewPickSurface(QGLView *view, QGLFramebufferObject *fbo,
- const QSize &areaSize);
-
- QPaintDevice *device() const;
- bool activate(QGLAbstractSurface *prevSurface);
- void deactivate(QGLAbstractSurface *nextSurface);
- QRect viewportGL() const;
-
-private:
- QGLView *m_view;
- QGLFramebufferObject *m_fbo;
- QRect m_viewportGL;
-};
-
-QGLViewPickSurface::QGLViewPickSurface
- (QGLView *view, QGLFramebufferObject *fbo, const QSize &areaSize)
- : QGLAbstractSurface(504)
- , m_view(view)
- , m_fbo(fbo)
- , m_viewportGL(QPoint(0, 0), areaSize)
-{
-}
-
-QPaintDevice *QGLViewPickSurface::device() const
-{
- return m_view;
-}
-
-bool QGLViewPickSurface::activate(QGLAbstractSurface *prevSurface)
-{
- Q_UNUSED(prevSurface);
- if (m_fbo)
- m_fbo->bind();
- return true;
-}
-
-void QGLViewPickSurface::deactivate(QGLAbstractSurface *nextSurface)
-{
- Q_UNUSED(nextSurface);
- if (m_fbo)
- m_fbo->release();
-}
-
-QRect QGLViewPickSurface::viewportGL() const
-{
- return m_viewportGL;
-}
-
-/*!
- Returns the registered object that is under the mouse position
- specified by \a point. This function may need to regenerate
- the contents of the pick buffer by repainting the scene
- with paintGL().
-
- \sa registerObject()
-*/
-QObject *QGLView::objectForPoint(const QPoint &point)
-{
- QPoint pt(point);
-
- // What is the size of the drawing area after correcting for stereo?
- // Also adjust the mouse position to always be in the left half.
- QSize areaSize = size();
- switch (d->stereoType) {
- case QGLView::LeftRight:
- case QGLView::RightLeft:
- areaSize = QSize(areaSize.width() / 2, areaSize.height());
- if (pt.x() >= areaSize.width())
- pt.setX(pt.x() - areaSize.width());
- break;
- case QGLView::TopBottom:
- case QGLView::BottomTop:
- areaSize = QSize(areaSize.width(), areaSize.height() / 2);
- if (pt.y() >= areaSize.height())
- pt.setY(pt.y() - areaSize.height());
- break;
- case QGLView::StretchedLeftRight:
- case QGLView::StretchedRightLeft: {
- int halfwid = areaSize.width() / 2;
- if (pt.x() >= halfwid)
- pt.setX((pt.x() - halfwid) * 2);
- else
- pt.setX(pt.x() * 2);
- break; }
- case QGLView::StretchedTopBottom:
- case QGLView::StretchedBottomTop: {
- int halfht = areaSize.height() / 2;
- if (pt.y() >= halfht)
- pt.setY((pt.y() - halfht) * 2);
- else
- pt.setY(pt.y() * 2);
- break; }
- default: break;
- }
-
- // Check the area boundaries in case a mouse move has
- // moved the pointer outside the window.
- if (pt.x() < 0 || pt.x() >= areaSize.width() ||
- pt.y() < 0 || pt.y() >= areaSize.height())
- return 0;
-
- // Do we need to refresh the pick buffer contents?
- QGLPainter painter(this);
- if (d->pickBufferForceUpdate) {
- // Initialize the painter, which will make the window context current.
- painter.setPicking(true);
- painter.clearPickObjects();
-
- // Create a framebuffer object as big as the window to act
- // as the pick buffer if we are single buffered. If we are
- // double-buffered, then use the window back buffer.
- bool useBackBuffer = doubleBuffer();
- if (!useBackBuffer) {
- QSize fbosize = QGL::nextPowerOfTwo(areaSize);
- if (!d->fbo) {
- d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
- } else if (d->fbo->size() != fbosize) {
- delete d->fbo;
- d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
- }
- }
-
- // Render the pick version of the scene.
- QGLViewPickSurface surface(this, d->fbo, areaSize);
- painter.pushSurface(&surface);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- painter.setEye(QGL::NoEye);
- painter.setCamera(d->camera);
- paintGL(&painter);
- painter.setPicking(false);
- painter.popSurface();
-
- // The pick buffer contents are now valid, unless we are using
- // the back buffer - we cannot rely upon it being valid next time.
- d->pickBufferForceUpdate = useBackBuffer;
- d->pickBufferMaybeInvalid = false;
- }
-
- // Pick the object under the mouse.
- if (d->fbo)
- d->fbo->bind();
- int objectId = painter.pickObject(pt.x(), areaSize.height() - 1 - pt.y());
- QObject *object = d->objects.value(objectId, 0);
- if (d->fbo)
- d->fbo->release();
-
- // Release the framebuffer object and return.
- painter.end();
- doneCurrent();
- return object;
-}
-
-void QGLView::sendEnterEvent(QObject *object)
-{
- QEvent event(QEvent::Enter);
- QCoreApplication::sendEvent(object, &event);
-}
-
-void QGLView::sendLeaveEvent(QObject *object)
-{
- QEvent event(QEvent::Leave);
- QCoreApplication::sendEvent(object, &event);
-}
-
-// Zoom in and out according to the change in wheel delta.
-void QGLView::wheel(int delta)
-{
- if (d->options & QGLView::FOVZoom) {
- //Use field-of view as zoom (much like a traditional camera)
- qreal scale = qAbs(viewDelta(delta, delta).x());
- if (delta < 0)
- scale = -scale;
- if (scale >= 0.0f)
- scale += 1.0f;
- else
- scale = 1.0f / (1.0f - scale);
- qreal fov = d->camera->fieldOfView();
- if (fov != 0.0f)
- d->camera->setFieldOfView(d->camera->fieldOfView() / scale);
- else
- d->camera->setViewSize(d->camera->viewSize() / scale);
- } else {
- // enable this to get wheel navigation that actually zooms by moving the
- // camera back, as opposed to making the angle of view wider.
- QVector3D viewVector= camera()->eye() - camera()->center();
- qreal zoomMag = viewVector.length();
- qreal zoomIncrement = -float(delta) / 100.0f;
- if (!qFuzzyIsNull(zoomIncrement))
- {
- zoomMag += zoomIncrement;
- if (zoomMag < 1.0f)
- zoomMag = 1.0f;
-
- QRay3D viewLine(camera()->center(), viewVector.normalized());
- camera()->setEye(viewLine.point(zoomMag));
- }
- }
-
-}
-
-// Pan left/right/up/down without rotating about the object.
-void QGLView::pan(int deltax, int deltay)
-{
- QPointF delta = viewDelta(deltax, deltay);
- QVector3D t = d->camera->translation(delta.x(), -delta.y(), 0.0f);
-
- // Technically panning the eye left should make the object appear to
- // move off to the right, but this looks weird on-screen where the user
- // actually thinks they are picking up the object and dragging it rather
- // than moving the eye. We therefore apply the inverse of the translation
- // to make it "look right".
- d->camera->setEye(d->camera->eye() - t);
- d->camera->setCenter(d->camera->center() - t);
-}
-
-// Rotate about the object being viewed.
-void QGLView::rotate(int deltax, int deltay)
-{
- int rotation = d->camera->screenRotation();
- if (rotation == 90 || rotation == 270) {
- qSwap(deltax, deltay);
- }
- if (rotation == 90 || rotation == 180) {
- deltax = -deltax;
- }
- if (rotation == 180 || rotation == 270) {
- deltay = -deltay;
- }
- qreal anglex = deltax * 90.0f / width();
- qreal angley = deltay * 90.0f / height();
- QQuaternion q = d->camera->pan(-anglex);
- q *= d->camera->tilt(-angley);
- d->camera->rotateCenter(q);
-}
-
-/*!
- Converts \a deltax and \a deltay into percentages of the
- view width and height. Returns a QPointF containing the
- percentage values, typically between -1 and 1.
-
- This function is typically used by subclasses to convert a
- change in mouse position into a relative distance travelled
- across the field of view.
-
- The returned value is corrected for the camera() screen
- rotation and view size.
-*/
-QPointF QGLView::viewDelta(int deltax, int deltay) const
-{
- int w = width();
- int h = height();
- bool scaleToWidth;
- qreal scaleFactor, scaleX, scaleY;
- QSizeF viewSize = d->camera->viewSize();
- if (w >= h) {
- if (viewSize.width() >= viewSize.height())
- scaleToWidth = true;
- else
- scaleToWidth = false;
- } else {
- if (viewSize.width() >= viewSize.height())
- scaleToWidth = false;
- else
- scaleToWidth = true;
- }
- int rotation = d->camera->screenRotation();
- if (rotation == 90 || rotation == 270) {
- scaleToWidth = !scaleToWidth;
- qSwap(deltax, deltay);
- }
- if (rotation == 90 || rotation == 180) {
- deltax = -deltax;
- }
- if (rotation == 180 || rotation == 270) {
- deltay = -deltay;
- }
- if (scaleToWidth) {
- scaleFactor = 2.0f / viewSize.width();
- scaleX = scaleFactor * ((qreal)h) / ((qreal)w);
- scaleY = scaleFactor;
- } else {
- scaleFactor = 2.0f / viewSize.height();
- scaleX = scaleFactor;
- scaleY = scaleFactor * ((qreal)w) / ((qreal)h);
- }
- return QPointF(deltax * scaleX / w, deltay * scaleY / h);
-}
-
-/*!
- \fn QPointF QGLView::viewDelta(const QPoint &delta) const
- \overload
-
- Converts the x and y components of \a delta into percentages
- of the view width and height. Returns a QPointF containing
- the percentage values, typically between -1 and 1.
-*/
-
-
-QT_END_NAMESPACE
diff --git a/src/threed/viewing/qglview.h b/src/threed/viewing/qglview.h
deleted file mode 100644
index 444854d9..00000000
--- a/src/threed/viewing/qglview.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtQuick3D 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 QGLVIEW_H
-#define QGLVIEW_H
-
-#include "qglpainter.h"
-#include "qglcamera.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Qt3D)
-
-class QGLViewPrivate;
-
-class Q_QT3D_EXPORT QGLView : public QGLWidget
-{
- Q_OBJECT
-public:
- explicit QGLView(QWidget *parent=0);
- explicit QGLView(const QGLFormat& format, QWidget *parent=0);
- ~QGLView();
-
- enum Option
- {
- ObjectPicking = 0x0001,
- ShowPicking = 0x0002,
- CameraNavigation = 0x0004,
- PaintingLog = 0x0008,
- FOVZoom = 0x0010
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QGLView::Options options() const;
- void setOptions(QGLView::Options value);
- void setOption(QGLView::Option option, bool value);
-
- enum StereoType
- {
- Hardware,
- RedCyanAnaglyph,
- LeftRight,
- RightLeft,
- TopBottom,
- BottomTop,
- StretchedLeftRight,
- StretchedRightLeft,
- StretchedTopBottom,
- StretchedBottomTop
- };
-
- QGLView::StereoType stereoType() const;
- void setStereoType(QGLView::StereoType type);
-
- void registerObject(int objectId, QObject *object);
- void deregisterObject(int objectId);
- QObject *objectForPoint(const QPoint &point);
-
- QGLCamera *camera() const;
- void setCamera(QGLCamera *camera);
-
- QVector3D mapPoint(const QPoint &point) const;
-
-protected:
- void initializeGL();
- void resizeGL(int w, int h);
- void paintGL();
- virtual void initializeGL(QGLPainter *painter);
- virtual void earlyPaintGL(QGLPainter *painter);
- virtual void paintGL(QGLPainter *painter) = 0;
-
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void mouseDoubleClickEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void leaveEvent(QEvent *e);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *e);
-#endif
- void keyPressEvent(QKeyEvent *e);
-
- QPointF viewDelta(int deltax, int deltay) const;
- QPointF viewDelta(const QPoint &delta) const
- { return viewDelta(delta.x(), delta.y()); }
-
-private Q_SLOTS:
- void cameraChanged();
-
-private:
- QGLViewPrivate *d;
-
- static void sendEnterEvent(QObject *object);
- static void sendLeaveEvent(QObject *object);
-
- void wheel(int delta);
- void pan(int deltax, int deltay);
- void rotate(int deltax, int deltay);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLView::Options)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/threed/viewing/viewing.pri b/src/threed/viewing/viewing.pri
deleted file mode 100644
index a6d7f7fd..00000000
--- a/src/threed/viewing/viewing.pri
+++ /dev/null
@@ -1,12 +0,0 @@
-INCLUDEPATH += $$PWD
-VPATH += $$PWD
-
-HEADERS += \
- viewing/qglcamera.h \
- viewing/qglcameraanimation.h \
- viewing/qglview.h
-
-SOURCES += \
- qglcamera.cpp \
- qglcameraanimation.cpp \
- qglview.cpp