qnanopainter icon indicating copy to clipboard operation
qnanopainter copied to clipboard

Incorrect drawing with QNANO_USE_RENDERNODE

Open ddobrev opened this issue 7 years ago • 1 comments
trafficstars

Let me start by expressing my gratitude to you for this excellent library. QQuickPaintedItem performs suboptimally, Shape renders poorly (seen in your example too), implementing updatePaintNode is difficult because of OpenGL, so an important niche remains which QNanoPainter fits in perfectly. I congratulate you. Having said that, I have a problem. It's most probably a mistake of mine but I have so far been unable to find it. I have this painting code:

void RoundProgressPainter::paint(QNanoPainter* painter)
{
    painter->beginPath();
    painter->setStrokeStyle(m_color);
    painter->setLineWidth(m_penWidth);
    painter->setLineCap(QNanoPainter::LineCap::CAP_ROUND);
    painter->arc(width() / 2,
                 height() /  2,
                 (height() - m_penWidth) / 2,
                 0,
                 m_progress * 2 * M_PI / 100.0);
    painter->stroke();
}

Using it without QNANO_USE_RENDERNODE (correctly) gives me this:

qquickframebufferobject

Using it with QNANO_USE_RENDERNODE gives me this:

qrendernode

I have a feeling I am making a simple noob mistake so please help me. If necessary, I can provide the rest of my C++ as well as its usage in QML.

ddobrev avatar Oct 14 '18 22:10 ddobrev

Hi and thanks! =)

I tested by copying your sources into helloitem.h like this:

    HelloItemPainter()
        : m_color(255,0,0,255)
        , m_penWidth(10)
        , m_progress(90)
    {
    }

    void paint(QNanoPainter *p)
    {
        // Painting code is shared as it's identical in all hello* examples
        paintHelloItem(p, width(), height());

        p->beginPath();
        p->setStrokeStyle(m_color);
        p->setLineWidth(m_penWidth);
        p->setLineCap(QNanoPainter::LineCap::CAP_ROUND);
        p->arc(width() / 2,
               height() /  2,
               (height() - m_penWidth) / 2,
               0,
               m_progress * 2 * M_PI / 100.0);
        p->stroke();
    }

Building it with and without QNANO_USE_RENDERNODE look both like this:

helloitem_with_arc

So my guess is that either some other part of code is messing things up (which shouldn't happen if only change you do is QNANO_USE_RENDERNODE?) or your OpenGL drivers have a bug... Does the same happen on different system?

QUItCoding avatar Oct 15 '18 04:10 QUItCoding