Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Replacement for QSGSimpleTextureNode
Forum Updated to NodeBB v4.3 + New Features

Replacement for QSGSimpleTextureNode

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Magnus21
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, it's the correct class, you have to do a bit more work though.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Magnus21
        wrote on last edited by
        #3

        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[0].set(this->pos.x()-SIZE,this->pos.y()-SIZE,0,0);
            vertices[1].set(this->pos.x()+SIZE,this->pos.y()-SIZE,1,0);
            vertices[2].set(this->pos.x()-SIZE,this->pos.y()+SIZE,0,1);
            vertices[3].set(this->pos.x()+SIZE,this->pos.y()+SIZE,1,1);
            node->appendChildNode(gnode);
        

        Full Source code

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved