I worked a little bit with openGL and found a solution that worked for me
The normal OpenGL examples used QSGGeometry::Point2D
to set up the verticies. But there is a Version with color support,too (QSGGeometry::defaultAttributes_ColoredPoint2D())
. So I can set up the verticies with
vertices[i].set(x, y, r,g, b, a);
//EDIT:
the next problem is that the gui freezes from time to time , if the QSGeometry-Object has to many verticies. I don't know why.
The GUI is slow down after allocate the memory for the verticies, so this approach has not good performance.
//EDIT 2:
I added a simplified code of the current updatePaint
-method. If the data object is very huge (>2.000.000 points), the widgets renders the points but than the whole gui is hanging and stuttering.
QSGNode *HistogramView::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
{
QSGGeometryNode *node = 0;
QSGGeometry *geometry = 0;
if (!oldNode) {
node = new QSGGeometryNode;
geometry = new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), data.size());
geometry->setDrawingModeelsize(GL_POINTS);
node->setGeometry(geometry);
node->setFlag(QSGNode::OwnsGeometry);
QSGVertexColorMaterial *material = new QSGVertexColorMaterial();
//material->setColor(QColor(255, 0, 0));
node->setMaterial(material);
node->setFlag(QSGNode::OwnsMaterial);
} else {
node = static_cast<QSGGeometryNode *>(oldNode);
geometry = node->geometry();
geometry->allocate(222);
}
QSGGeometry::ColoredPoint2D *vertices = geometry->vertexDataAsColoredPoint2D();
for (int i = 0; i < data.size(); i++) {
vertices[id].set(x, y,red, green, blue, 255);
}
}
}
node->markDirty(QSGNode::DirtyGeometry);
return node;
}
I could localize the error.
after calling initializing the QSGGeometry
-object(
geometry = new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), data.size());
) the gui is very slow.
Greetings