Is it possible control Line_Width of individual lines in gloo (webgl in Python)?

302 Views Asked by At

In VisPy with gloo backend, The with of lines drawn via 3D coordinates can modified through

GL.glLineWidth(max(width1, 1.))

at once, altogether.

Is there any way to give the widths/thickness of line using array like colors? Should I modify gloo or can set the Line_Width with some command?

    VERTEX_SHADER = """
        varying vec4 v_color;
        void main(void) {
            gl_Position = $transform($to_vec4($position));
            v_color = $color;
        }
    """
#            gl_LineWidth = v_color;
#        varying vec4 v_color;

    FRAGMENT_SHADER = """
        varying vec4 v_color;
        void main() {
            gl_FragColor = v_color;
        }
    """
1

There are 1 best solutions below

0
On BEST ANSWER

Is there any way to give the widths/thickness of line using array like colors?

no

Should I modify gloo or can set the Line_Width with some command?

I'm not sure what this means. Like you mention you can se the line with globally with

GL.glLineWidth(width);

Unfortunately line widths > 1 are in general not supported. The WebGL1 spec via the OpenGL ES 2.0 spec says the max required size is 1.0. OpenGL core, on which WebGL on Linux and Mac is implemented says line widths > 1.0 are deprecated. Angle on Windows on which OpenGL ES is emulated also only supports line widths of 1.0. Effetively that means line width > 1.0 are pretty much not supported anywhere

So basically if you want lines > 1 pixel think you need to make them from polygons