Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

why QSGTexture::WrapMode::Repeat not work?



  • void shapeObject::setQSGColor(QSGGeometryNode& aNode, const QColor& aColor){
    QSGOpaqueTextureMaterial *material = new QSGOpaqueTextureMaterial();

    auto img = QImage(4, 1, QImage::Format_ARGB32);
    img.fill("transparent");
    {
        QPainter pnt(&img);
        pnt.fillRect(0, 0, 2, 1, aColor);
    }
    auto txt = m_window->window()->createTextureFromImage(img);
    txt->setHorizontalWrapMode(QSGTexture::WrapMode::Repeat); //not work!?
    material->setTexture(txt);
    aNode.setMaterial(material);
    aNode.setFlag(QSGNode::OwnsMaterial);
    aNode.markDirty(QSGNode::DirtyMaterial);
    

    }
    whatever which wrapmode I set for the texture, it always works as the QSGTexture::WrapMode::ClampToEdge for the coordinates being out of [0, 1].
    Is this a bug? My Qt version is Qt5.12.2? Or is there anything wrong for my codes?



  • it has been solved. we should use the same named api of the material rather than texture...


Log in to reply