class mrpt::opengl::Program

A resource handling helper for OpenGL Shader “programs”.

The OpenGL “program” resource will be freed upon destruction or when clear() is called.

See also:

CRenderizable

#include <mrpt/opengl/Shader.h>

class Program
{
public:
    // typedefs

    typedef std::shared_ptr<Program> Ptr;

    // structs

    struct Data;

    // construction

    Program();

    //
methods

    bool empty() const;
    void clear();
    bool linkProgram(std::vector<Shader>& shaders, mrpt::optional_ref<std::string> outErrorMessages = std::nullopt);
    void declareUniform(const std::string& name);
    void declareAttribute(const std::string& name);
    unsigned int programId() const;
    int uniformId(const char* name) const;
    int attributeId(const char* name) const;
    bool hasUniform(const char* name) const;
    bool hasAttribute(const char* name) const;
    void dumpProgramDescription(std::ostream& o) const;
};

Methods

void clear()

Frees the shader program in OpenGL.

bool linkProgram(
    std::vector<Shader>& shaders,
    mrpt::optional_ref<std::string> outErrorMessages = std::nullopt
    )

Links an OpenGL program with all shader code fragments previously inserted into shaders.

Parameters:

shaders

The shader code fragments. Will be moved into this Program object, who will become the owner from now on and will eventually free its resources.

outErrorMessages

If provided, build errors will be saved here. If not, they will dumped to std::cerr

Returns:

false on error.

void dumpProgramDescription(std::ostream& o) const

Prints a textual summary of the program.