MRPT  1.9.9
List of all members | Public Member Functions | Private Attributes
mrpt::opengl::Shader Class Reference

Detailed Description

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

Definition at line 37 of file Shader.h.

#include <mrpt/opengl/Shader.h>

Public Member Functions

 Shader ()=default
 
 ~Shader ()
 
Shaderoperator= (const Shader &)=delete
 
 Shader (const Shader &)=delete
 
Shaderoperator= (Shader &&)
 
 Shader (Shader &&)
 
bool empty () const
 
void clear ()
 Frees the shader program in OpenGL. More...
 
bool compile (unsigned int type, const std::string &shaderCode, mrpt::optional_ref< std::string > outErrorMessages=std::nullopt)
 Build a shader from source code. More...
 
unsigned int handle () const
 

Private Attributes

unsigned int m_shader = 0
 

Constructor & Destructor Documentation

◆ Shader() [1/3]

mrpt::opengl::Shader::Shader ( )
default

◆ ~Shader()

Shader::~Shader ( )

Definition at line 21 of file Shader.cpp.

References mrpt::containers::clear().

Here is the call graph for this function:

◆ Shader() [2/3]

mrpt::opengl::Shader::Shader ( const Shader )
delete

◆ Shader() [3/3]

Shader::Shader ( Shader &&  o)

Definition at line 28 of file Shader.cpp.

Member Function Documentation

◆ clear()

void Shader::clear ( )

Frees the shader program in OpenGL.

Definition at line 34 of file Shader.cpp.

◆ compile()

bool Shader::compile ( unsigned int  type,
const std::string &  shaderCode,
mrpt::optional_ref< std::string >  outErrorMessages = std::nullopt 
)

Build a shader from source code.

Parameters
[in]typeAny valid argument to glCreateShader()
[in]shaderCodeThe shading source code. Tip: users can read it from a file with mrpt::io::file_get_contents().
[out]outErrorMessagesIf provided, build errors will be saved here. If not, they will dumped to std::cerr
Returns
false on error.

Definition at line 43 of file Shader.cpp.

References mrpt::containers::clear(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ empty()

bool mrpt::opengl::Shader::empty ( ) const
inline

Definition at line 47 of file Shader.h.

References m_shader.

◆ handle()

unsigned int mrpt::opengl::Shader::handle ( ) const
inline

Definition at line 63 of file Shader.h.

References m_shader.

◆ operator=() [1/2]

Shader& mrpt::opengl::Shader::operator= ( const Shader )
delete

◆ operator=() [2/2]

Shader & Shader::operator= ( Shader &&  o)

Definition at line 22 of file Shader.cpp.

References m_shader.

Member Data Documentation

◆ m_shader

unsigned int mrpt::opengl::Shader::m_shader = 0
private

Definition at line 66 of file Shader.h.

Referenced by empty(), handle(), and operator=().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020