summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2020-04-23 02:08:55 +0300
committerJere Tuliniemi <jere.tuliniemi@qt.io>2020-04-27 10:55:38 +0300
commite2c3ae53ddc0d0a5a5b0b6c76e427689d0b2d826 (patch)
tree048ae9033d647fcfa93c36c5bacc9b951893b59f
parent5ae9d1039383f7dadaa7229785820f0ae32fb67a (diff)
Document QQuickImageProvider usage
Task-number: QT3DS-4049 Change-Id: I655de11b904a8828d7c428f91c0874e74106fdf5 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-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)
{