summaryrefslogtreecommitdiffstats
path: root/src/api/studio3d/q3dspresentation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/studio3d/q3dspresentation.cpp')
-rw-r--r--src/api/studio3d/q3dspresentation.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/api/studio3d/q3dspresentation.cpp b/src/api/studio3d/q3dspresentation.cpp
index f0ca867..752ac21 100644
--- a/src/api/studio3d/q3dspresentation.cpp
+++ b/src/api/studio3d/q3dspresentation.cpp
@@ -1126,6 +1126,30 @@ void Q3DSPresentation::setAttribute(const QString &elementPath, const QString &a
"image://colors/blue" where "image://" tells the runtime to look for an
image provider, "colors" is the image provider id and rest are the image
id the provider uses to create the image.
+
+ Usage is similar to the examples in https://doc.qt.io/qt-5/qquickimageprovider.html
+
+ \badcode
+ // Example implementation of a request function
+ // This returns a 50 x 50 px size green texture as a QPixmap
+ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
+ {
+ // Size needs to be more than 0,0 or nothing will be drawn
+ if (size)
+ *size = QSize(50, 50);
+
+ QPixmap pixmap(50, 50);
+ pixmap.fill(QColor("green"));
+ return pixmap;
+ }
+
+ // Image providers are added to the presentation after viewer creation
+ viewer.create(&window, &context);
+ viewer.presentation()->addImageProvider("green", new ImageProvider());
+
+ // Use as texture
+ viewer.presentation()->setAttribute("Scene.Layer.Rectangle.Material.diffusemap", "sourcepath", "image://green");
+ \endcode
*/
void Q3DSPresentation::addImageProvider(const QString &providerId, QQmlImageProviderBase *provider)
{