[Python] How to display a lot of line_strips efficiently with ModernGL

Discussão em 'Python' iniciado por Stack, Novembro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I need to display many (a lot) 3d trajectories with modernGL.
    For now, I chain the trajectories and I create two arrays only (one for all the vertices and one for their colors) that I pass as params of context.vertex_array. See the code below:

    vao = ctx.vertex_array(prog,
    [(ctx.buffer(all_vertices.tobytes(), "3f", "in_vert"),
    (ctx.buffer(all_colors.tobytes(), "4f", "in_color")]
    )
    vao.render(mode=mGL.LINE_STRIP_ADJACENCY)


    To avoid "color gradient lines" in-between each trajectory, I double the last and the first point of each trajectory, and I give to these new points a transparent color. I also fight with the dedicated shader to give these points a far z-depth.
    I wonder if another solution exists, more efficient, without fps loss ? For exemple providing one vertex_array and several index buffers ?

    Thanks in advance for your answers !!

    Continue reading...

Compartilhe esta Página