Class Shader
Defined in File Shader.h
Nested Relationships
Nested Types
Class Documentation
-
class Shader
A resource handling helper for OpenGL “Shader” compiled code fragment.
The OpenGL shader resource will be freed upon destruction or when clear() is called. Normally, users want shader(s) to be linked into a mrpt::opengl::Program.
See also
CRenderizable
Public Functions
-
Shader() = default
-
~Shader()
-
inline bool empty() const
-
void clear()
Frees the shader program in OpenGL.
-
bool compile(unsigned int type, const std::vector<std::string> &shaderCode, mrpt::optional_ref<std::string> outErrorMessages = std::nullopt)
Build a shader from source code.
- Parameters:
type – [in] Any valid argument to glCreateShader()
shaderCode – [in] The shading source code(s). One or more code blocks are allowed, that will be merged together. Tip: users can read it from a file with mrpt::io::file_get_contents().
outErrorMessages – [out] If provided, build errors will be saved here. If not, they will dumped to std::cerr
- Returns:
false on error.
-
inline unsigned int handle() const
-
Shader() = default