From e2c3ae53ddc0d0a5a5b0b6c76e427689d0b2d826 Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Thu, 23 Apr 2020 02:08:55 +0300 Subject: Document QQuickImageProvider usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QT3DS-4049 Change-Id: I655de11b904a8828d7c428f91c0874e74106fdf5 Reviewed-by: Tomi Korpipää Reviewed-by: Miikka Heikkinen --- src/api/studio3d/q3dspresentation.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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) { -- cgit v1.2.3