Replacement for QSGSimpleTextureNode
I need to render images in OpenGL, so I found QSGSimpleTextureNode.
But it says there, that this class is obsolete and should not be used. What is the replacement for this class?
I found QSGImageNode, which looks very similar, but this is only an abstract class, where nothing at all seems to be implemented. So what should I use instead of QSGSimpleTextureNode?
AFAIK, it's the correct class, you have to do a bit more work though.
Btw, just in case someone else was looking for a solution to the same problem:
I did not want to reimplement everything, so I just create a texture from QQuickView::createTextureFromImage which unfortunately requires an instance, so I just created a dummy instance to create textures. Finally I create 4 texture coordinates to let the texture be displayed:
gnode = new QSGGeometryNode; geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0); geometry->setDrawingMode(GL_TRIANGLE_STRIP); gnode->setGeometry(geometry); gnode->setFlag(QSGNode::OwnsGeometry); material = new QSGTextureMaterial(); QImage img = QImage(2*SIZE, 2*SIZE, QImage::Format_RGB16); img.fill(color); // icon background color QSvgRenderer renderer(iconPath); QPainter painter(&img); renderer.render(&painter); // paint the icon on top of it material = new QSGTextureMaterial; texture = view->createTextureFromImage(img); texture->setMipmapFiltering(QSGTexture::Linear); texture->bind(); material->setTexture(texture); gnode->setMaterial(material); gnode->setFlag(QSGNode::OwnsMaterial); geometry->allocate(4); vertices = geometry->vertexDataAsTexturedPoint2D(); vertices.set(this->pos.x()-SIZE,this->pos.y()-SIZE,0,0); vertices.set(this->pos.x()+SIZE,this->pos.y()-SIZE,1,0); vertices.set(this->pos.x()-SIZE,this->pos.y()+SIZE,0,1); vertices.set(this->pos.x()+SIZE,this->pos.y()+SIZE,1,1); node->appendChildNode(gnode);