Go to the documentation of this file.
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 resource handling helper for OpenGL Shader "programs".
mrpt::math::CMatrixFloat44 mv_matrix
Model-view matrix.
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.
const mrpt::opengl::CRenderizable * object
const mrpt::opengl::Program * shader
mrpt::opengl::TRenderMatrices renderState
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...
MATRIX44 getHomogeneousMatrixVal() const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
The base class of 3D objects that can be directly rendered through OpenGL.
mrpt::opengl::CText & labelObject() const
Returns or constructs (in its first invokation) the associated mrpt::opengl::CText object representin...
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.
float getScaleX() const
Get the current scaling factor in one axis.
bool isShowNameEnabled() const
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
float getScaleZ() const
Get the current scaling factor in one axis.
#define THROW_EXCEPTION(msg)
#define ASSERT_(f)
Defines an assertion mechanism.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
CMatrixFixed< double, 4, 4 > CMatrixDouble44
void setString(const std::string &s)
Sets the text to display.
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
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.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
int uniformId(const char *name) const
unsigned int programId() const
mrpt::math::CMatrixFloat44 p_matrix
Projection matrix, computed by renderNormalScene() from all the parameters above.
bool hasToUpdateBuffers() const
Returns whether notifyChange() has been invoked since the last call to renderUpdateBuffers(),...
Context for calls to render()
Each element in the queue to be rendered for each keyframe.
const std::string & getName() const
Returns the name of the object.
mrpt::opengl::shader_id_t shader_id
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...
Rendering state related to the projection and model-view matrices.
const T * data() const
Return raw pointer to row-major data buffer.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object
void updateBuffers() const
Calls renderUpdateBuffers() and clear the flag that is set with notifyChange()
const mrpt::opengl::TLightParameters * lights
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
This base provides a set of functions for maths stuff.
std::string getString() const
Return the current text associated to this label.
Lighting parameters, mostly for triangle shaders.
virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const
Provide a representative point (in object local coordinates), used to sort objects by eye-distance wh...
virtual shader_list_t requiredShaders() const
Returns the ID of the OpenGL shader program required to render this class.
const mrpt::opengl::TRenderMatrices * state
bool hasUniform(const char *name) const
mrpt::math::CMatrixFloat44 pmv_matrix
Result of p_matrix * mv_matrix.
The namespace for 3D scene representation and rendering.
A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location.
bool isVisible() const
Is the object visible?
std::string std::string format(std::string_view fmt, ARGS &&... args)
#define MRPT_PROFILE_FUNC_START
virtual void render(const RenderContext &rc) const =0
Implements the rendering of 3D objects in each class derived from CRenderizable.
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |