class mrpt::opengl::LinesProxy
Overview
GPU-side proxy for rendering lines and wireframes.
This proxy handles rendering of any CVisualObject that uses the WIREFRAME shader, such as:
CSetOfLines
CSimpleLine
CGridPlaneXY / CGridPlaneXZ
CAxis
Wireframe rendering of meshes
Any object derived from VisualObjectParams_Lines
The proxy manages:
Vertex buffer (line endpoints as pairs)
Color buffer (per-vertex RGBA colors)
Line rendering parameters (width, anti-aliasing)
VAO for efficient attribute binding
Line rendering features:
Variable line width
Per-vertex colors
Optional anti-aliasing (GL_LINE_SMOOTH)
Alpha blending for transparency
Typical data flow:
compile() : Upload initial line vertices and colors to GPU
updateBuffers() : Re-upload when lines change
render() : Draw lines every frame
See also:
LinesProxyBase, mrpt::viz::VisualObjectParams_Lines
#include <mrpt/opengl/LinesProxy.h> class LinesProxy: public mrpt::opengl::LinesProxyBase { public: // structs struct LineParams; // fields mrpt::math::CMatrixFloat44 m_modelMatrix = mrpt::math::CMatrixFloat44::Identity(); bool m_visible = true; // construction LinesProxy(); // methods virtual void compile(const mrpt::viz::CVisualObject* sourceObj); virtual void updateBuffers(const mrpt::viz::CVisualObject* sourceObj); virtual void render(const RenderContext& rc) const; virtual const char* typeName() const; virtual bool cullEligible() const; mrpt::math::TBoundingBoxf getBoundingBox(const mrpt::poses::CPose3D& objPose) const; virtual std::vector<shader_id_t> requiredShaders() const; virtual bool castsShadows() const; virtual mrpt::math::TBoundingBoxf getBoundingBoxLocal() const; void setSourceObject(std::weak_ptr<mrpt::viz::CVisualObject> obj); std::shared_ptr<mrpt::viz::CVisualObject> getSourceObject() const; bool isSourceValid() const; bool sourceNeedsUpdate() const; };
Inherited Members
public: // methods virtual void compile(const mrpt::viz::CVisualObject* sourceObj) = 0; virtual void updateBuffers(const mrpt::viz::CVisualObject* sourceObj); virtual void render(const RenderContext& rc) const = 0; virtual std::vector<shader_id_t> requiredShaders() const = 0; virtual bool castsShadows() const; virtual mrpt::math::TBoundingBoxf getBoundingBoxLocal() const; virtual const char* typeName() const; RenderableProxy& operator = (const RenderableProxy&); RenderableProxy& operator = (RenderableProxy&&); virtual void compile(const mrpt::viz::CVisualObject* sourceObj); virtual void updateBuffers(const mrpt::viz::CVisualObject* sourceObj); virtual void render(const RenderContext& rc) const; virtual const char* typeName() const;
Fields
mrpt::math::CMatrixFloat44 m_modelMatrix = mrpt::math::CMatrixFloat44::Identity()
Model matrix: object local frame -> world frame.
Composed from the object’s pose (and parent container poses). Set during compilation by CompiledScene.
bool m_visible = true
Effective visibility (accounts for parent container visibility).
Updated by CompiledScene during dirty-object updates.
Methods
virtual void compile(const mrpt::viz::CVisualObject* sourceObj)
Initial compilation: uploads object data to GPU.
This is called once when the proxy is first created. It should:
Create OpenGL buffers (VBOs, VAOs, textures)
Upload initial vertex/color/normal/texture data
Cache any frequently-used values
Must be called from OpenGL context thread
After this call, the proxy should be ready to render
Parameters:
sourceObj |
The abstract viz object (read-only access) |
virtual void updateBuffers(const mrpt::viz::CVisualObject* sourceObj)
Incremental update: refreshes GPU buffers with changed data.
This is called when the source object’s dirty flag is set (hasToUpdateBuffers() returns true). It should:
Re-upload only the changed data (vertices, colors, etc.)
Be as efficient as possible (don’t recompile everything)
Must be called from OpenGL context thread
Default implementation calls compile() - override for efficiency
Parameters:
sourceObj |
The abstract viz object (read-only access) |
virtual void render(const RenderContext& rc) const
Renders this object using the provided context.
This is called every frame for visible objects. It should:
Bind appropriate buffers (VAO, VBO, textures)
Set shader uniforms (model matrix, material properties, etc.)
Issue draw calls (glDrawArrays, glDrawElements, etc.)
Must be called from OpenGL context thread
The shader program is already bound when this is called
Common matrices (P, V, M) are already uploaded by CompiledViewport
Parameters:
rc |
Rendering context (shader, matrices, lights) |
virtual const char* typeName() const
Returns a human-readable type name for this proxy.
Used for debugging and logging.
virtual bool cullEligible() const
Should this object be checked for frustum culling?
Some objects (like skyboxes) should never be culled even if their bounding box is outside the view frustum.
Returns:
true if eligible for culling (default: true)
mrpt::math::TBoundingBoxf getBoundingBox(const mrpt::poses::CPose3D& objPose) const
Returns the object’s bounding box in world coordinates.
This applies the object’s pose transformation to the local bbox.
Parameters:
objPose |
The object’s SE(3) pose in world frame |
Returns:
Transformed bounding box
virtual std::vector<shader_id_t> requiredShaders() const
Returns the list of shader programs this object needs.
Most objects use a single shader, but some may use multiple (e.g., different shaders for shadow map pass vs. normal rendering).
Returns:
Vector of shader IDs, typically with 1 element
virtual bool castsShadows() const
Does this object cast shadows?
Used to determine if the object should be rendered during the shadow map generation pass (1st pass of shadow rendering).
Returns:
true if object casts shadows (default: true)
virtual mrpt::math::TBoundingBoxf getBoundingBoxLocal() const
Returns the object’s bounding box in local coordinates.
Used for frustum culling and spatial queries. The bounding box should be as tight as possible for efficient culling.
This is in the object’s local frame, before applying pose transform
Returns:
Bounding box, or empty box if not applicable
void setSourceObject(std::weak_ptr<mrpt::viz::CVisualObject> obj)
Sets the source object reference.
Called by CompiledScene during compilation.
std::shared_ptr<mrpt::viz::CVisualObject> getSourceObject() const
Returns the source object, or nullptr if it has been deleted.
bool isSourceValid() const
Check if source object still exists.
bool sourceNeedsUpdate() const
Check if source object has pending changes (dirty flag)