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

Detailed Description

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

Definition at line 77 of file Shader.h.

#include <mrpt/opengl/Shader.h>

Public Types

using Ptr = std::shared_ptr< Program >
 

Public Member Functions

 Program ()=default
 
 ~Program ()
 
bool empty () const
 
void clear ()
 Frees the shader program in OpenGL. More...
 
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. More...
 
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
 Prints a textual summary of the program. More...
 

Private Attributes

std::vector< Shaderm_shaders
 
unsigned int m_program = 0
 
std::unordered_map< std::string, int > m_uniforms
 OpenGL Uniforms/attribs defined by the user as inputs/outputs in shader code. More...
 
std::unordered_map< std::string, int > m_attribs
 

Member Typedef Documentation

◆ Ptr

Definition at line 83 of file Shader.h.

Constructor & Destructor Documentation

◆ Program()

mrpt::opengl::Program::Program ( )
default

◆ ~Program()

Program::~Program ( )

Definition at line 85 of file Shader.cpp.

References mrpt::containers::clear().

Here is the call graph for this function:

Member Function Documentation

◆ attributeId()

int mrpt::opengl::Program::attributeId ( const char *  name) const
inline

Definition at line 114 of file Shader.h.

References m_attribs.

Referenced by mrpt::opengl::CRenderizableShaderWireFrame::render(), mrpt::opengl::CRenderizableShaderText::render(), mrpt::opengl::CRenderizableShaderTriangles::render(), and mrpt::opengl::CRenderizableShaderPoints::render().

Here is the caller graph for this function:

◆ clear()

void Program::clear ( )

Frees the shader program in OpenGL.

Definition at line 87 of file Shader.cpp.

◆ declareAttribute()

void Program::declareAttribute ( const std::string &  name)

Definition at line 172 of file Shader.cpp.

References ASSERT_, mrpt::containers::empty(), THROW_EXCEPTION, and THROW_EXCEPTION_FMT.

Here is the call graph for this function:

◆ declareUniform()

void Program::declareUniform ( const std::string &  name)

Definition at line 152 of file Shader.cpp.

References ASSERT_, mrpt::containers::empty(), THROW_EXCEPTION, and THROW_EXCEPTION_FMT.

Here is the call graph for this function:

◆ dumpProgramDescription()

void Program::dumpProgramDescription ( std::ostream &  o) const

Prints a textual summary of the program.

Definition at line 194 of file Shader.cpp.

References ASSERT_, mrpt::containers::empty(), mrpt::format(), and mrpt::math::size().

Here is the call graph for this function:

◆ empty()

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

Definition at line 85 of file Shader.h.

References m_program.

◆ hasAttribute()

bool mrpt::opengl::Program::hasAttribute ( const char *  name) const
inline

Definition at line 120 of file Shader.h.

References m_attribs.

◆ hasUniform()

bool mrpt::opengl::Program::hasUniform ( const char *  name) const
inline

Definition at line 116 of file Shader.h.

References m_uniforms.

Referenced by mrpt::opengl::processRenderQueue(), and mrpt::opengl::CRenderizableShaderTriangles::render().

Here is the caller graph for this function:

◆ linkProgram()

bool Program::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
[in,out]shadersThe shader code fragments. Will be moved into this Program object, who will become the owner from now on and will eventually free its resources.
[out]outErrorMessagesIf provided, build errors will be saved here. If not, they will dumped to std::cerr
Returns
false on error.

Definition at line 109 of file Shader.cpp.

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

Here is the call graph for this function:

◆ programId()

unsigned int mrpt::opengl::Program::programId ( ) const
inline

Definition at line 107 of file Shader.h.

References ASSERT_, and m_program.

Referenced by mrpt::opengl::processRenderQueue().

Here is the caller graph for this function:

◆ uniformId()

int mrpt::opengl::Program::uniformId ( const char *  name) const
inline

Definition at line 113 of file Shader.h.

References m_uniforms.

Referenced by mrpt::opengl::processRenderQueue(), mrpt::opengl::CRenderizableShaderTriangles::render(), mrpt::opengl::CRenderizableShaderPoints::render(), and mrpt::opengl::CText::render().

Here is the caller graph for this function:

Member Data Documentation

◆ m_attribs

std::unordered_map<std::string, int> mrpt::opengl::Program::m_attribs
private

Definition at line 136 of file Shader.h.

Referenced by attributeId(), and hasAttribute().

◆ m_program

unsigned int mrpt::opengl::Program::m_program = 0
private

Definition at line 130 of file Shader.h.

Referenced by empty(), and programId().

◆ m_shaders

std::vector<Shader> mrpt::opengl::Program::m_shaders
private

Definition at line 129 of file Shader.h.

◆ m_uniforms

std::unordered_map<std::string, int> mrpt::opengl::Program::m_uniforms
private

OpenGL Uniforms/attribs defined by the user as inputs/outputs in shader code.

See also
declareUniform(), declareAttribute();

Definition at line 136 of file Shader.h.

Referenced by hasUniform(), and uniformId().




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