Hi Gunnar, Thank you for your reply.
> An alternative approach would be to generate the line segments for the dashes and combining that with QSGGeometry::>defaultAttributes_ColorizedPoint2D() and QSGVertexColorMaterial. It will be a bit more work to prepare and take up a bit more >memory, but on the plus side, it will batch in the renderer, so it will probably be faster to draw if you have many instances of these >dashed objects. The modelview/cos based implementation you link to will not support batching because each line needs a unique >shader state, the model view matrix and perhaps also the source point. Initially I wanted to choose this approach but then I thought that with custom shaders it makes more sense as I can separate geometry and material. I didn't know that batching is not applicable to shaders. Are there any ways to do it with shaders and allow batching? Another question - is there any way to draw text solely in Scene Graph using QSG classes? I need to draw a lot of text labels and what only came to my mind is to draw them using QPainter on a QImage and store it as a QSGSimpleTextureNode in the node itself. Regards, Artem 2016-06-06 7:39 GMT+02:00 Gunnar Sletta <gun...@sletta.org>: > > > On 05 Jun 2016, at 00:50, Artem Fedoskin <afedosk...@gmail.com> wrote: > > > > As I understand there is no way to draw dashed line in Qt Quick Scene > Graph so I decided to create shader material to do this. > > I'm trying to apply this approach > http://korkd.com/2012/02/15/dashed-lines/ to this example > http://doc.qt.io/qt-5/qtquick-scenegraph-simplematerial-example.html. > > • How can I get ModelView matrix in my shader? I need to multiply > ModelView matrix by vertex to get its current position. > > Hi Artem, > > The model view matrix is part of the QSGMaterialShader::RenderState that > is passed in to the QSGMaterialShader::updateState() function which you use > to apply the state for you material. > > > • How in this example works > QSGGeometry::defaultAttributes_TexturedPoint2D? What values does it store? > > The vertex shader in the code you link only uses a colorized 2D point, one > vec4 for the position and one vec4 for the color, so you want that kind of > vertex structure. QSGGeometry::defaultAttributes_ColorizedPoint2D() > implements that for 2D at least. > > > • How can I pass sourcePoint (the first point of a line) to my > shader? > > It is a uniform, so you write it during the > QSGMaterialShader::updateState() function. > > > If someone knows better way to draw dashed line I would be grateful to > you for telling me it. > > An alternative approach would be to generate the line segments for the > dashes and combining that with > QSGGeometry::defaultAttributes_ColorizedPoint2D() and > QSGVertexColorMaterial. It will be a bit more work to prepare and take up a > bit more memory, but on the plus side, it will batch in the renderer, so it > will probably be faster to draw if you have many instances of these dashed > objects. The modelview/cos based implementation you link to will not > support batching because each line needs a unique shader state, the model > view matrix and perhaps also the source point. > > cheers, > Gunnar > > > > > Regards, Artem > > > > _______________________________________________ > > Interest mailing list > > Interest@qt-project.org > > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest