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

    • Type: Bug
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.0
    • Fix Version/s: None
    • Component/s: Quick: SceneGraph
    • Labels:
      None
    • Platform/s:
      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

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

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes