PlottingOpenGL::StreamingPolyLineRenderer
PlottingOpenGL::StreamingPolyLineRenderer
Optimized polyline renderer with incremental GPU buffer updates. More…
#include <StreamingPolyLineRenderer.hpp>
Inherits from PlottingOpenGL::IBatchRenderer
Public Functions
| Name | |
|---|---|
| StreamingPolyLineRenderer(std::string shader_base_path =““, float capacity_multiplier =2.0f) Construct a StreamingPolyLineRenderer. |
|
| ~StreamingPolyLineRenderer() override | |
| virtual bool | initialize() override Initialize GPU resources (VAOs, VBOs, shaders). |
| virtual void | cleanup() override Release all GPU resources. |
| virtual bool | isInitialized() const override Check if the renderer has been successfully initialized. |
| virtual void | render(glm::mat4 const & view_matrix, glm::mat4 const & projection_matrix) override Render the current batch with the given View and Projection matrices. |
| virtual bool | hasData() const override Check if there is any data to render. |
| virtual void | clearData() override Clear all uploaded data (but keep GPU resources allocated). |
| void | updateData(CorePlotting::RenderablePolyLineBatch const & batch) Update buffer with new batch data using incremental strategy. |
| void | uploadData(CorePlotting::RenderablePolyLineBatch const & batch) Force a full re-upload of the buffer (bypasses incremental logic). |
| void | setTimingEnabled(bool enabled) Enable/disable timing measurement. |
| bool | isTimingEnabled() const |
| RenderTimingStats const & | getTimingStats() const Get timing statistics from the last frame. |
| void | resetTimingStats() Reset timing statistics (clears moving averages). |
| float | getCacheHitRatio() const Get cache hit ratio (0.0 = all misses, 1.0 = all hits). |
| void | setComparisonTolerance(float tolerance) Set the tolerance for comparing vertices. |
Additional inherited members
Public Functions inherited from PlottingOpenGL::IBatchRenderer
| Name | |
|---|---|
| virtual | ~IBatchRenderer() =default |
Protected Functions inherited from PlottingOpenGL::IBatchRenderer
| Name | |
|---|---|
| IBatchRenderer() =default | |
| IBatchRenderer(IBatchRenderer const & ) =delete | |
| IBatchRenderer & | operator=(IBatchRenderer const & ) =delete |
| IBatchRenderer(IBatchRenderer && ) =delete | |
| IBatchRenderer & | operator=(IBatchRenderer && ) =delete |
Detailed Description
class PlottingOpenGL::StreamingPolyLineRenderer;Optimized polyline renderer with incremental GPU buffer updates.
Uses glBufferSubData to update only changed portions of the vertex buffer when time series data scrolls.
Public Functions Documentation
function StreamingPolyLineRenderer
explicit StreamingPolyLineRenderer(
std::string shader_base_path ="",
float capacity_multiplier =2.0f
)Construct a StreamingPolyLineRenderer.
Parameters:
- shader_base_path Base path to shader directory (empty = embedded)
- capacity_multiplier How much extra buffer capacity to allocate (default: 2.0x)
function ~StreamingPolyLineRenderer
~StreamingPolyLineRenderer() overridefunction initialize
virtual bool initialize() overrideInitialize GPU resources (VAOs, VBOs, shaders).
Return: true if initialization succeeded
Reimplements: PlottingOpenGL::IBatchRenderer::initialize
Must be called with a valid, current OpenGL context. Can be called multiple times (will reinitialize if needed).
function cleanup
virtual void cleanup() overrideRelease all GPU resources.
Reimplements: PlottingOpenGL::IBatchRenderer::cleanup
Should be called before the OpenGL context is destroyed. Safe to call even if initialize() was never called.
function isInitialized
virtual bool isInitialized() const overrideCheck if the renderer has been successfully initialized.
Reimplements: PlottingOpenGL::IBatchRenderer::isInitialized
function render
virtual void render(
glm::mat4 const & view_matrix,
glm::mat4 const & projection_matrix
) overrideRender the current batch with the given View and Projection matrices.
Parameters:
- view_matrix Global camera/view transformation
- projection_matrix Projection to NDC
Reimplements: PlottingOpenGL::IBatchRenderer::render
The Model matrix is stored per-batch in the renderable data structure and will be combined with the provided VP matrices.
function hasData
virtual bool hasData() const overrideCheck if there is any data to render.
Return: true if the renderer has data uploaded and ready to draw
Reimplements: PlottingOpenGL::IBatchRenderer::hasData
function clearData
virtual void clearData() overrideClear all uploaded data (but keep GPU resources allocated).
Reimplements: PlottingOpenGL::IBatchRenderer::clearData
function updateData
void updateData(
CorePlotting::RenderablePolyLineBatch const & batch
)Update buffer with new batch data using incremental strategy.
Parameters:
- batch The new polyline batch
Precondition:
- initialize() must have been called and returned true before the first call (enforcement: runtime_check)
- A valid OpenGL context must be current on the calling thread (enforcement: none) [CRITICAL]
- batch.line_start_indices.size() == batch.line_vertex_counts.size() (topology arrays must be parallel) (enforcement: none) [IMPORTANT]
- For each i: batch.line_start_indices[i] + batch.line_vertex_counts[i] <= batch.vertices.size() / 2 (no index exceeds the vertex buffer) (enforcement: none) [CRITICAL]
- batch.thickness > 0 (required by glLineWidth; zero or negative produces a GL error) (enforcement: none) [LOW]
Compares new data with cached data and uses glBufferSubData to update only the changed regions when possible. Falls back to full re-upload when:
- Buffer capacity is insufficient
- Topology changes (number of lines, line lengths)
- First upload after clearData()
function uploadData
void uploadData(
CorePlotting::RenderablePolyLineBatch const & batch
)Force a full re-upload of the buffer (bypasses incremental logic).
Precondition:
- initialize() must have been called and returned true before the first call (enforcement: runtime_check)
- A valid OpenGL context must be current on the calling thread (enforcement: none) [CRITICAL]
- batch.line_start_indices.size() == batch.line_vertex_counts.size() (topology arrays must be parallel) (enforcement: none) [IMPORTANT]
- For each i: batch.line_start_indices[i] + batch.line_vertex_counts[i] <= batch.vertices.size() / 2 (no index exceeds the vertex buffer; checked against the cached batch used by render()) (enforcement: none) [CRITICAL]
- batch.thickness > 0 (required by glLineWidth in render(); zero or negative produces a GL error) (enforcement: none) [LOW]
Use this when you know the data has changed significantly, such as when loading a new dataset.
An empty batch.vertices is handled gracefully: the buffer is cleared and the function returns without touching the GPU.
function setTimingEnabled
inline void setTimingEnabled(
bool enabled
)Enable/disable timing measurement.
When enabled, timing data is collected for each updateData/render call. Disable in production for slightly better performance.
function isTimingEnabled
inline bool isTimingEnabled() constfunction getTimingStats
inline RenderTimingStats const & getTimingStats() constGet timing statistics from the last frame.
function resetTimingStats
inline void resetTimingStats()Reset timing statistics (clears moving averages).
function getCacheHitRatio
float getCacheHitRatio() constGet cache hit ratio (0.0 = all misses, 1.0 = all hits).
A “hit” means incremental update was possible. A “miss” means full re-upload was required.
function setComparisonTolerance
inline void setComparisonTolerance(
float tolerance
)Set the tolerance for comparing vertices.
Default: 0.0
Vertices within this tolerance are considered equal. Useful when floating point precision causes minor variations.
Updated on 2026-11-13 at 20:25:41 +0000