class mrpt::opengl::TexturedTrianglesProxy

Overview

GPU-side proxy for rendering textured triangle meshes.

This proxy handles rendering of any CVisualObject that uses textured triangle shaders, such as:

  • CTexturedPlane

  • CMesh (with texture)

  • CMeshFast (with texture)

  • CSetOfTexturedTriangles

  • Any object derived from VisualObjectParams_TexturedTriangles

The proxy manages:

  • Vertex buffer (3D triangle vertices)

  • Normal buffer (per-vertex normals for lighting)

  • Color buffer (per-vertex RGBA colors)

  • Texture coordinate buffer (UV coordinates)

  • Texture object (diffuse map)

  • VAO for efficient attribute binding

Textured rendering features:

  • Phong lighting with texture modulation

  • Optional transparency via alpha channel or separate alpha texture

  • Texture filtering (nearest/linear interpolation)

  • Mipmapping support

  • Face culling modes

  • Shadow casting

Shader selection:

  • Normal rendering: TEXTURED_TRIANGLES_LIGHT or TEXTURED_TRIANGLES_NO_LIGHT

  • Shadow 1st pass: TEXTURED_TRIANGLES_SHADOW_1ST

  • Shadow 2nd pass: TEXTURED_TRIANGLES_SHADOW_2ND

See also:

TexturedTrianglesProxyBase, mrpt::viz::VisualObjectParams_TexturedTriangles

#include <mrpt/opengl/TexturedTrianglesProxy.h>

class TexturedTrianglesProxy: public mrpt::opengl::TexturedTrianglesProxyBase
{
public:
    // structs

    struct TextureParams;

    // construction

    TexturedTrianglesProxy();

    // 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 std::vector<shader_id_t> requiredShaders() const;
    virtual const char* typeName() const;
    virtual mrpt::math::TBoundingBoxf getBoundingBoxLocal() const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<RenderableProxy> Ptr;

    // 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 std::vector<shader_id_t> requiredShaders() const;
    virtual const char* typeName() const;
    virtual void compile(const mrpt::viz::CVisualObject* sourceObj);
    virtual void updateBuffers(const mrpt::viz::CVisualObject* sourceObj);
    virtual void render(const RenderContext& rc) const;
    virtual std::vector<shader_id_t> requiredShaders() const;
    virtual const char* typeName() const;

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 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 const char* typeName() const

Returns a human-readable type name for this proxy.

Used for debugging and logging.

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