Dashed lines

207 views
Skip to first unread message

Fahri Basegmez

unread,
Jun 28, 2020, 8:06:47 PM6/28/20
to vispy
Hi,

I just started learning Vispy. I have some questions.

I am going through the documents and examples but could not find an example about stippled lines. Do I need to create a custom DashedLine visual?

Can I redraw a line (I presume that it has to be a line with "method='agg' ") with a dashed style?

If I use gloo instead of the visuals, how can I draw a dashed line?

Can I use the old style opengl commands like

glPushAttrib(GL_ENABLE_BIT); 

glLineStipple(1, 0xAAAA);  # [1]
glEnable(GL_LINE_STIPPLE);
glBegin(GL_LINES);
glVertex3f(-.5,.5,-.5);
glVertex3f(.5,.5,-.5);
glEnd();

glPopAttrib();


If I can is there an example?

I also have a question about using multiple shaders in the same canvas.  Is there an example?

Thanks in advance,

Fahri

David Hoese

unread,
Jun 29, 2020, 1:16:05 PM6/29/20
to vispy
Hi Fahri,

As far as I understand there is no direct translation from old stippled lines and new versions of OpenGL. You can either use the default `gl` line method for LineVisual and make your own dash lines by generating the individual line segments yourself (use connect='segments') or you could look at the agg method and updating it to work better for dashed lines. It seems there was something started here with a "DashAtlas" class but it is hardcoded to be solid lines:


Otherwise, I'm not sure we have support for dashed lines in any other visual. If you can find a modern method for drawing dashed lines (the old methods are not supported by OpenGL anymore) then it should be relatively trivial to get it working with vispy, but right now Visual versus gloo interfaces probably won't make a difference. Sorry. I'm sure that's not the response you were hoping for.

Dave

Fahri Basegmez

unread,
Jun 29, 2020, 4:02:12 PM6/29/20
to vispy
Dave, thanks for the prompt reply.  I found this paper titled Shader-Based Antialiased,Dashed, Stroked Polylines at http://jcgt.org/published/0002/02/08/paper.pdf.  It also talks about "dash atlas".  I did not realize that GL_LINE_STIPPLE was deprecated in OpenGL 3.1.

Thanks again,

Fahri

David Hoese

unread,
Jun 29, 2020, 7:14:28 PM6/29/20
to vi...@googlegroups.com
Ah that's by Nico (@rougier on github)! He's one of the original
maintainers of vispy and glumpy. You may want to look at his glumpy
project (similar to vispy but currently has different goals) and see if
he's updated this DashAtlas implementation there. We might be able to
copy things over to vispy.

If you want more help I'd suggest creating a github issue and mentioning
@rougier and me (@djhoese) in it.

Dave

On 6/29/20 11:02 AM, Fahri Basegmez wrote:
> Dave, thanks for the prompt reply.  I found this paper titled
> Shader-Based Antialiased,Dashed, Stroked Polylines at
> http://jcgt.org/published/0002/02/08/paper.pdf.  It also talks about
> "dash atlas".  I did not realize that GL_LINE_STIPPLE was deprecated in
> OpenGL 3.1.
>
> Thanks again,
>
> Fahri
>
> On Monday, June 29, 2020 at 9:16:05 AM UTC-4, David Hoese wrote:
>
> Hi Fahri,
>
> As far as I understand there is no direct translation from old
> stippled lines and new versions of OpenGL. You can either use the
> default `gl` line method for LineVisual and make your own dash lines
> by generating the individual line segments yourself (use
> connect='segments') or you could look at the agg method and updating
> it to work better for dashed lines. It seems there was something
> started here with a "DashAtlas" class but it is hardcoded to be
> solid lines:
>
> https://github.com/vispy/vispy/blob/b5f6228c7c4ec734206e9556033f5c3e7941616c/vispy/visuals/line/line.py#L411-L412
> <https://github.com/vispy/vispy/blob/b5f6228c7c4ec734206e9556033f5c3e7941616c/vispy/visuals/line/line.py#L411-L412>
> https://github.com/vispy/vispy/blob/b5f6228c7c4ec734206e9556033f5c3e7941616c/vispy/visuals/line/dash_atlas.py
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "vispy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vispy/43XR8-bm5VE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vispy+un...@googlegroups.com
> <mailto:vispy+un...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/vispy/7678e998-42aa-4150-96e2-c98ec03dd261o%40googlegroups.com
> <https://groups.google.com/d/msgid/vispy/7678e998-42aa-4150-96e2-c98ec03dd261o%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages