17 #include <Eigen/Dense>    32 #if MRPT_HAS_OPENGL_GLUT    35     const char* curClassName = 
nullptr;
    38         for (
const auto& objPtr : objs)
    40             if (!objPtr) 
continue;
    61                 auto scale = CMatrixFloat44::Identity();
    76             _.pmv_matrix.asEigen() =
    77                 _.p_matrix.asEigen() * _.mv_matrix.asEigen();
    83             Eigen::Vector4f lrp_hm(lrp.
x, lrp.
y, lrp.
z, 1.0f);
    84             const auto lrp_proj = (_.pmv_matrix.asEigen() * lrp_hm).eval();
    86                 (lrp_proj(3) != 0) ? lrp_proj(2) / lrp_proj(3) : .001f;
    90             for (
const auto shader_id : lst_shaders)
   111                 rq[DefaultShaderID::TEXT].emplace(
   117     catch (
const exception& e)
   120             "Exception while rendering class '%s':\n%s",
   121             curClassName ? curClassName : 
"(undefined)", e.what());
   128     std::map<shader_id_t, mrpt::opengl::Program::Ptr>& shaders,
   131 #if MRPT_HAS_OPENGL_GLUT   134     for (
const auto& rqSet : rq)
   140         CHECK_OPENGL_ERROR();
   143         const auto& rqMap = rqSet.second;
   146         for (
auto it = rqMap.rbegin(); it != rqMap.rend(); ++it)
   151             const auto IS_TRANSPOSED = GL_TRUE;
   153                 shader.
uniformId(
"p_matrix"), 1, IS_TRANSPOSED,
   157                 shader.
uniformId(
"mv_matrix"), 1, IS_TRANSPOSED,
   162                     shader.
uniformId(
"pmv_matrix"), 1, IS_TRANSPOSED,
   167                 glUniform1i(shader.
uniformId(
"textureSampler"), 0);
   179                 CHECK_OPENGL_ERROR();
   187 #if MRPT_HAS_OPENGL_GLUT   188 void mrpt::opengl::checkOpenGLErr_impl(
   189     unsigned int glErrorCode, 
const char* filename, 
int lineno)
   191     if (glErrorCode == GL_NO_ERROR) 
return;
   193         "[%s:%i] OpenGL error: %s", filename, lineno,
   194         reinterpret_cast<const char*>(gluErrorString(glErrorCode)));
   195     std::cerr << 
"[gl_utils::checkOpenGLError] " << sErr << std::endl;
 A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location...
 
const mrpt::opengl::Program * shader
 
virtual void render(const RenderContext &rc) const =0
Implements the rendering of 3D objects in each class derived from CRenderizable. 
 
const mrpt::opengl::TRenderMatrices * state
 
float getScaleX() const
Get the current scaling factor in one axis. 
 
const T * data() const
Return raw pointer to row-major data buffer. 
 
#define THROW_EXCEPTION(msg)
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
 
const mrpt::opengl::CRenderizable * object
 
bool hasToUpdateBuffers() const
Returns whether notifyChange() has been invoked since the last call to renderUpdateBuffers(), meaning the latter needs to be called again before rendering. 
 
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects. 
 
mrpt::opengl::shader_id_t shader_id
 
void processRenderQueue(const RenderQueue &rq, std::map< shader_id_t, mrpt::opengl::Program::Ptr > &shaders, const mrpt::opengl::TLightParameters &lights)
After enqueForRendering(), actually executes the rendering tasks, grouped shader by shader...
 
The base class of 3D objects that can be directly rendered through OpenGL. 
 
const mrpt::opengl::TLightParameters * lights
 
virtual void enqueForRenderRecursive([[maybe_unused]] const mrpt::opengl::TRenderMatrices &state, [[maybe_unused]] RenderQueue &rq) const
Process all children objects recursively, if the object is a container. 
 
mrpt::opengl::CText & labelObject() const
Returns or constructs (in its first invokation) the associated mrpt::opengl::CText object representin...
 
Context for calls to render() 
 
#define MRPT_PROFILE_FUNC_START
 
unsigned int programId() const
 
#define ASSERT_(f)
Defines an assertion mechanism. 
 
std::string getString() const
Return the current text associated to this label. 
 
virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const
Provide a representative point (in object local coordinates), used to sort objects by eye-distance wh...
 
This base provides a set of functions for maths stuff. 
 
mrpt::math::CMatrixFloat44 pmv_matrix
Result of p_matrix * mv_matrix. 
 
void enqueForRendering(const mrpt::opengl::CListOpenGLObjects &objs, const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq)
Processes, recursively, all objects in the list, classifying them by shader programs into a list suit...
 
bool isVisible() const
Is the object visible? 
 
const std::string & getName() const
Returns the name of the object. 
 
bool hasUniform(const char *name) const
 
mrpt::math::CMatrixFloat44 mv_matrix
Model-view matrix. 
 
Rendering state related to the projection and model-view matrices. 
 
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
 
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime. 
 
Each element in the queue to be rendered for each keyframe. 
 
virtual shader_list_t requiredShaders() const
Returns the ID of the OpenGL shader program required to render this class. 
 
bool isShowNameEnabled() const
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
mrpt::opengl::TRenderMatrices renderState
 
The namespace for 3D scene representation and rendering. 
 
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object. 
 
int uniformId(const char *name) const
 
const mrpt::poses::CPose3D & getPoseRef() const
Returns a const ref to the 3D pose of the object as mrpt::poses::CPose3D (which explicitly contains t...
 
float getScaleY() const
Get the current scaling factor in one axis. 
 
MATRIX44 getHomogeneousMatrixVal() const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
 
A resource handling helper for OpenGL Shader "programs". 
 
mrpt::math::CMatrixFloat44 p_matrix
Projection matrix, computed by renderNormalScene() from all the parameters above. ...
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
 
CMatrixFixed< double, 4, 4 > CMatrixDouble44
 
void updateBuffers() const
Calls renderUpdateBuffers() and clear the flag that is set with notifyChange() 
 
Lighting parameters, mostly for triangle shaders. 
 
float getScaleZ() const
Get the current scaling factor in one axis. 
 
void setString(const std::string &s)
Sets the text to display. 
 
std::map< shader_id_t, std::multimap< float, RenderQueueElement > > RenderQueue
A queue for rendering, sorted by shader program to minimize changes of OpenGL shader programs while r...