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

QSGGeometryNode will not be drawn if it does not contain vertex when first draw.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.15.0
    • Quick: SceneGraph
    • None
    • macOS

    Description

      Hi ,

      Please see the attachment, 

      in function:

      updatePaintNode()

      if I initialize the  QSGGeometry with 0 vertex, so in the first call of updatePaintNode, the vertex number is 0. Then in the rest of the calls when I  allocate vertices according to the number of the samples. the geometrynode can not be drawn any more. 

      To fix this, I need to initialize the QSGGeometry with at least 1 vertex even through I don't have any points at this time. 

      Here is the content of updatePaintNode.

      // code placeholder
      QSGNode * TGraph::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData)
      {
          qDebug()<<"lenght of sample "<<m_samples.count();
          QSGGeometryNode *node = nullptr;
          QSGGeometry *geometry = nullptr;
         if(!oldNode)
         {
             node = new QSGGeometryNode;
             geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 1);//0
             geometry->setLineWidth(2);
             geometry->setDrawingMode(QSGGeometry::DrawLines);
             node->setGeometry(geometry);
             node->setFlag(QSGNode::OwnsGeometry);
      //! [5] //! [6]
             QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
             material->setColor(QColor(255, 0, 0));
             node->setMaterial(material);
             node->setFlag(QSGNode::OwnsMaterial);
         }
         else {
             node = static_cast<QSGGeometryNode *>(oldNode);
             geometry = node->geometry();
             geometry->allocate(m_samples.count());
         }
      
         for(int i=0;i<m_samples.count();i++)
         {
             QSGGeometry::Point2D *v = geometry->vertexDataAsPoint2D();
             for (int i=0; i<m_samples.size(); ++i) {
                 v[i].set(m_samples.at(i).x(),m_samples.at(i).y());
             }
         }
         node->markDirty(QSGNode::DirtyGeometry);
          return node;
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            janichol Andy Nichols
            yorkchenqt1989 York Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes