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
- 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.
- _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_SIZEin 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.
- _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 concatenatednp.float32array and tile_ranges maps(tx, ty)to(vbo_offset, vertex_count)forglDrawArrays.
- 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
glDrawArrayscall. When tiled (array exceeds max texture size), iterates over visible tiles, binding each tile’s texture and setting per-tile offset uniforms.