[Interest] Custom QQuickItem with smooth painting
ruslan at khvmntk.ru
Wed Jan 28 00:33:00 CET 2015
Thanks for the answer!
In my case setting samples makes the output even worse then without
setting it. I've tried 16 and 255, nothing works.
Setting format.setSamples() removes any antialiasing at all.
Without format.setSamples() - http://pbrd.co/1EO9GRh
With format.setSamples() - http://pbrd.co/1EO9KjX
The yellow star is my shape I want to paint with antialiasing. The
rectangle is QML Rectangle with radius set.
27.01.2015 17:22, Gunnar Sletta пишет:
> You can either rely on multisample antialiasing by doing:
> QQuickView view;
> QSurfaceFormat format = view.requestedFormat();
> format.setSamples(16); // set as high as possible, will be cut back to
> what is supported
> By requesting a multisampled OpenGL context, all primitives will be
> antialiased. Depending on your hardware, this might come at a
> performance cost though.
> If you don’t want to rely on multisampling, you need to create
> triangles along the edges of your line to “fake” an antialiased edge,
> like you already found out that the default rectangle implementation
>> On 27 Jan 2015, at 02:49, Ruslan Moukhlynin <ruslan at khvmntk.ru
>> <mailto:ruslan at khvmntk.ru>> wrote:
>> Hi all!
>> In my app I use some custom QML element, for simplicity it just a line.
>> So I overrided QQuickItem::updatePaintNode and inside it I paint my
>> QSGGeometry *geometry = new
>> QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2);
>> geometry->vertexDataAsPoint2D().set(0, 0);
>> geometry->vertexDataAsPoint2D().set(width(), height());
>> QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
>> material->setColor(QColor(255, 0, 0));
>> QSGGeometryNode *node = new QSGGeometryNode;
>> But this line looks so ugly. There is no antialiasing at all here.
>> Ok, I 've looked through QSGDefaultRectangleNode source from
>> /$QTDIR/Src/qtdeclarative/src/quick/scenegraph/ and tried to
>> implement its QSGSmoothColorMaterial instead of QSGFlatColorMaterial
>> but nothing works, I just get segmentation fault.
>> I can't see call stack, just some assembler code so I cannot find the
>> problem line in my code.
>> So my question is very simple - how can I paint smooth line in custom
>> QQuickItem item? Any advice, example or suggestions will be greatly
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest