wolfhece.opengl.polyline_shader2d
Shared-resource polyline shader for vector rendering.
Renders polylines as geometry-shader-extruded quads with support for: - Variable width along the polyline - Dash / dot patterns - Glow effect - Animation (pulse, marching ants)
The shader program is compiled ONCE and reused for all vectors.
Author: HECE - University of Liege, Pierre Archambeau Date: 2026
Copyright (c) 2026 University of Liege. All rights reserved.
Module Contents
- class wolfhece.opengl.polyline_shader2d.PolylineShader2D[source]
Shared-resource polyline shader with VBO management.
A single instance is shared across all vector/zone rendering. Call
draw_polyline()for each polyline to render.- _instance: PolylineShader2D | None = None[source]
- classmethod get_instance() PolylineShader2D[source]
Return the singleton instance, creating it if needed.
- static _compile_shader(shader_type: int, path: pathlib.Path) int[source]
Compile a single GLSL shader from path.
- draw_polyline(vbo_data: numpy.ndarray, vertex_count: int, mvp: numpy.ndarray, viewport: tuple[int, int], color: tuple[float, float, float, float], line_width: float = 2.0, width_in_pixels: bool = True, aa_radius: float = 0.06, dash_enabled: bool = False, dash_length: float = 10.0, gap_length: float = 5.0, dash_offset: float = 0.0, glow_enabled: bool = False, glow_width: float = 0.4, glow_color: tuple[float, float, float, float] = (1.0, 1.0, 1.0, 0.4), anim_phase: float = 0.0, anim_mode: int = 0, join_style: int = 0, join_size: float = 1.0)[source]
Draw a single polyline with the shader pipeline.
- Parameters:
vbo_data – float32 array of shape
(N, 4)—[x, y, dist, width]per vertex.vertex_count – Number of vertices in vbo_data.
mvp – 4×4 projection matrix (column-major float32).
viewport –
(width_px, height_px)of the viewport.color –
(r, g, b, a)each in[0, 1].line_width – Full visible width of the line (pixels or world units), same semantics as
glLineWidth.width_in_pixels – If
True, line_width is in pixels.aa_radius – Anti-aliasing smoothing (0–1 in edge space).
dash_enabled – Enable the dash pattern.
dash_length – Dash length in world units.
gap_length – Gap length in world units.
dash_offset – Pattern offset for animation.
glow_enabled – Enable the glow halo.
glow_width – Glow halo extent as fraction of core half-width (e.g. 0.4 adds 40% extra width on each side).
glow_color –
(r, g, b, a)for the glow.anim_phase – Animation phase
[0, 1].anim_mode –
0= none,1= pulse alpha,2= marching ants.join_style –
0= miter,1= bevel,2= round.join_size – Join radius multiplier (
1.0= line half-width).
- wolfhece.opengl.polyline_shader2d.build_polyline_vbo(vertices: list, widths: numpy.ndarray | None = None) tuple[numpy.ndarray, int][source]
Build VBO data for a polyline from a list of wolfvertex objects.
Each segment is emitted as four vertices for
GL_LINES_ADJACENCY(prev, start, end, next) to be consumed by the geometry shader for miter join computation.- Parameters:
vertices – List of objects with
.xand.yattributes.widths – Optional per-vertex width multipliers (length N). Defaults to
1.0for all vertices.
- Returns:
(vbo_data, vertex_count)where vbo_data is a contiguous float32 array of shape(vertex_count, 4)and vertex_count is the number of vertices (= 4 × number of segments).