Class Shader

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()
Shader &operator=(const Shader&) = delete
Shader(const Shader&) = delete
Shader &operator=(Shader&&)
Shader(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
struct Data

Public Functions

void destroy()

Public Members

unsigned int shader = 0
std::thread::id creationThread = {}
bool inPostponedDestructionQueue = false