Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-23095

Changing texture of a QGLMaterial is not applied to QDeclarativeItem3D

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • Qt3D 1.0, 5.0.0
    • Qt3D TP2
    • Qt3D
    • None
    • Reproducible with codereview.qt-project.org:qt/quick3d commit 5344685a on desktop Linux.
    • I6af2944255506173041c8dd70cc359819df6d052

    Description

      In Qt3D, if we attach a QGLMaterial to a QGLSceneNode like this

      m_material = new QGLMaterial;
      m_node->setMaterial(m_material);
      m_node->setEffect(QGL::LitDecalTexture2D);
      

      and then update the texture like this

      QGLTexture2D *texture = new QGLTexture2D;
      texture->setImage(image);
      m_material->setTexture(texture);
      update(); // paintGL() calls m_node->draw(...)
      

      then the texture is updated on the displayed 3D object.

      We can do the same using QtQuick3D by creating an Item3D in QML

      Cube {
          effect: Effect { }
      }
      

      and then providing the cube's QDeclarativeItem3D to C++ code, which creates a QGLMaterial and updates the texture:

      void SomeClass::setItem(QDeclarativeItem3D *item)
      {
          m_item = item;
          m_material = new QGLMaterial;
          m_item->effect()->setMaterial(m_material);
      }
      
      void SomeClass::updateTexture()
      {
          QGLTexture2D *texture = new QGLTexture2D;
          texture->setImage(image);
          m_material->setTexture(texture);
          m_item->update();
      }
      

      However, in this case the texture shown on the item is not updated.

      This is demonstrated in the two attached applications, widget.tar.gz and quick.tar.gz.

      Attachments

        1. quick.tar.gz
          31 kB
        2. widget.tar.gz
          12 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chham Christopher Ham (closed Nokia identity) (Inactive)
            gastockw Gareth Stockwell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes