wolfhece.opengl.wolf_array_shader2d

Shared-resource 2D shader rendering for WolfArray.

Instead of creating a separate WolfArrayPlotShader per grid cell (each with its own shader program, z-texture upload, palette upload), we compile the shader program ONCE, upload the z-texture and palette ONCE, concatenate all visible quad-centers into a SINGLE VBO, and issue a SINGLE glDrawArrays call.

Author: HECE - University of Liege, Pierre Archambeau Date: 2024

Copyright (c) 2024 University of Liege. All rights reserved.

Module Contents

wolfhece.opengl.wolf_array_shader2d.SHADER_DIR[source]
wolfhece.opengl.wolf_array_shader2d._DTYPE_GL_MAP[source]
class wolfhece.opengl.wolf_array_shader2d.WolfArrayShader2D(owner)[source]

Manages shared OpenGL resources for 2D shader rendering of a WolfArray.

Holds a back-reference to the owning WolfArray to access grid data, palette, mapviewer, and LOD helpers.

_owner[source]
_program = None[source]
_locs = None[source]
_ztexture_id = None[source]
_palette_id = None[source]
_vao = None[source]
_vbo = None[source]
_merged_count = 0[source]
_visible_key = None[source]
_quad_cache[source]
_color_values_buf[source]
_pal_values = None[source]
_pal_size = 0[source]
_ztext_ready = False[source]
_pal_ready = False[source]
_dtype_define = None[source]
_tile_textures[source]
_tile_size = None[source]
_n_tiles = (1, 1)[source]
_tiled = False[source]
_tile_ranges[source]
_tile_visible_key = None[source]
_init_resources(dtype_define=None)[source]

Compile the shared shader program and locate uniforms.

Parameters:

dtype_define – Optional preprocessor define to inject into the geometry shader (‘SIGNED_INTEGER_DATA’ or ‘UNSIGNED_INTEGER_DATA’). When None the shader uses sampler2DRect (float textures).

_ensure_ztexture()[source]

Upload the z-texture to the GPU.

If the array fits within GL_MAX_RECTANGLE_TEXTURE_SIZE in both dimensions, a single rectangle texture is created (fast path). Otherwise the data is split into a grid of tile textures, each within the hardware limit.

_ensure_palette()[source]

Upload the palette 1-D texture to the GPU.

cleanup()[source]

Release all shared GL resources.

_ensure_vao_vbo()[source]

Create the shared VAO/VBO pair (once).

_upload_vbo(data)[source]

Upload float32 vertex data to the shared VBO.

_set_common_uniforms(wa, lod)[source]

Set uniforms shared between tiled and non-tiled draw paths.

_build_tile_vbo_data(wa, lod, istart, iend, jstart, jend)[source]

Group visible quad centers by texture tile and merge into one VBO.

Returns:

(merged_vbo, tile_ranges) where merged_vbo is a concatenated np.float32 array and tile_ranges maps (tx, ty) to (vbo_offset, vertex_count) for glDrawArrays.

draw(sx: float = None, sy: float = None, xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None)[source]

Draw using a single shared shader program.

When the array fits in a single texture, issues a single glDrawArrays call. When tiled (array exceeds max texture size), iterates over visible tiles, binding each tile’s texture and setting per-tile offset uniforms.