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:
#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(); void use(); void setInt(const char* uniformName, int value) const; void setFloat( const char* uniformName, float value, bool failIfNotExists = true ) const; void setFloat3( const char* uniformName, float v1, float v2, float v3 ) const; void setFloat4( const char* uniformName, float v1, float v2, float v3, float v4 ) const; 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.
void use()
Activates the program, calling glUseProgram() with this program ID.
void setInt(const char* uniformName, int value) const
Set uniform variables:
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.