namespace mrpt::opengl

Overview

The namespace for 3D scene representation and rendering.

See also the summary page of the mrpt-opengl library for more info and thumbnails of many of the render primitive.

namespace opengl {

// namespaces

namespace mrpt::opengl::graph_tools;
namespace mrpt::opengl::internal;
namespace mrpt::opengl::stock_objects;

// typedefs

typedef Scene COpenGLScene;
typedef Viewport COpenGLViewport;
typedef std::deque<CRenderizable::Ptr> CListOpenGLObjects;
typedef std::map<shader_id_t, std::multimap<float, RenderQueueElement>> RenderQueue;
typedef uint8_t shader_id_t;
typedef std::vector<shader_id_t> shader_list_t;
typedef unsigned int texture_name_t;
typedef int texture_unit_t;

// enums

enum CUBE_TEXTURE_FACE;
enum TCullFace;
enum TOpenGLFontStyle;
enum predefined_voxel_sets_t;

// structs

struct DefaultShaderID;
struct FrameBufferBinding;
struct RenderQueueElement;
struct RenderQueueStats;
struct T2DTextData;
struct TFontParams;
struct TLightParameters;
struct TRenderMatrices;
struct TTriangle;
struct texture_name_unit_t;

// classes

class Buffer;
class CAngularObservationMesh;
class CArrow;
class CAssimpModel;
class CAxis;
class CBox;
class CCamera;
class CColorBar;
class CCylinder;
class CDisk;
class CEllipsoid2D;
class CEllipsoid3D;
class CEllipsoidInverseDepth2D;
class CEllipsoidInverseDepth3D;
class CEllipsoidRangeBearing2D;
class CFBORender;
class CFrustum;

template <int DIM>
class CGeneralizedEllipsoidTemplate;

class CGridPlaneXY;
class CGridPlaneXZ;
class CMesh;
class CMesh3D;
class CMeshFast;
class COctoMapVoxels;

template <class Derived>
class COctreePointRenderer;

class CPlanarLaserScan;
class CPointCloud;
class CPointCloudColoured;
class CPolyhedron;
class CRenderizable;
class CRenderizableShaderPoints;
class CRenderizableShaderText;
class CRenderizableShaderTexturedTriangles;
class CRenderizableShaderTriangles;
class CRenderizableShaderWireFrame;
class CSetOfLines;
class CSetOfObjects;
class CSetOfTexturedTriangles;
class CSetOfTriangles;
class CSimpleLine;
class CSkyBox;
class CSphere;
class CText;
class CText3D;
class CTextMessageCapable;
class CTexturedPlane;
class CVectorField2D;
class CVectorField3D;
class FrameBuffer;

template <int DEPTH_LUT_NUM_BITS = 18>
class OpenGLDepth2LinearLUTs;

class PLY_Exporter;
class PLY_Importer;

template <class POINTCLOUD>
class PointCloudAdapter;

template <>
class PointCloudAdapter<mrpt::maps::CColouredPointsMap>;

template <>
class PointCloudAdapter<mrpt::opengl::CPointCloud>;

template <>
class PointCloudAdapter<mrpt::maps::CPointsMapXYZIRT>;

template <>
class PointCloudAdapter<mrpt::maps::CSimplePointsMap>;

template <>
class PointCloudAdapter<mrpt::opengl::CPointCloudColoured>;

template <>
class PointCloudAdapter<mrpt::maps::CPointsMap>;

template <>
class PointCloudAdapter<mrpt::maps::CWeightedPointsMap>;

template <>
class PointCloudAdapter<mrpt::maps::CPointsMapXYZI>;

template <>
class PointCloudAdapter<pcl::PointCloud<pcl::PointXYZRGB>>;

template <>
class PointCloudAdapter<mrpt::obs::CObservation3DRangeScan>;

template <>
class PointCloudAdapter<pcl::PointCloud<pcl::PointXYZRGBA>>;

template <>
class PointCloudAdapter<pcl::PointCloud<pcl::PointXYZ>>;

class Program;
class Scene;
class Shader;
class Texture;
class VertexArrayObject;
class Viewport;
class Visualizable;
class mrptEventGLPostRender;
class mrptEventGLPreRender;

// global variables

static constexpr int MATERIAL_DIFFUSE_TEXTURE_UNIT = 0;
static constexpr int SHADOW_MAP_TEXTURE_UNIT = 1;

// global functions

void enqueueForRendering(
    const mrpt::opengl::CListOpenGLObjects& objs,
    const mrpt::opengl::TRenderMatrices& state,
    RenderQueue& rq,
    const bool skipCullChecks,
    const bool is1stShadowMapPass,
    RenderQueueStats* stats = nullptr
    );

void processRenderQueue(
    const RenderQueue& rq,
    std::map<shader_id_t, mrpt::opengl::Program::Ptr>& shaders,
    const mrpt::opengl::TLightParameters& lights,
    const std::optional<unsigned int>& depthMapTextureId = std::nullopt
    );

template <class POSE_PDF>
CSetOfObjects::Ptr posePDF2opengl(const POSE_PDF& o);

mrpt::serialization::CArchive& operator >> (mrpt::serialization::CArchive& in, CPolyhedron::TPolyhedronEdge& o);
mrpt::serialization::CArchive& operator << (mrpt::serialization::CArchive& out, const CPolyhedron::TPolyhedronEdge& o);
mrpt::serialization::CArchive& operator >> (mrpt::serialization::CArchive& in, CPolyhedron::TPolyhedronFace& o);
mrpt::serialization::CArchive& operator << (mrpt::serialization::CArchive& out, const CPolyhedron::TPolyhedronFace& o);

template <class T>
CSetOfLines::Ptr& operator << (CSetOfLines::Ptr& l, const T& s);

CSetOfLines::Ptr& operator << (CSetOfLines::Ptr& l, const mrpt::math::TSegment3D& s);
CSetOfObjects::Ptr& operator << (CSetOfObjects::Ptr& s, const CRenderizable::Ptr& r);

template <class T>
CSetOfObjects::Ptr& operator << (CSetOfObjects::Ptr& o, const std::vector<T>& v);

template <class T>
CSetOfTriangles::Ptr& operator << (CSetOfTriangles::Ptr& s, const T& t);

CSetOfTriangles::Ptr& operator << (CSetOfTriangles::Ptr& s, const mrpt::opengl::TTriangle& t);
Program::Ptr LoadDefaultShader(const shader_id_t id);
void registerAllClasses_mrpt_opengl();

std::tuple<double, bool, bool> depthAndVisibleInView(
    const CRenderizable* obj,
    const mrpt::opengl::TRenderMatrices& objState,
    const bool skipCullChecks
    );

Scene::Ptr& operator << (Scene::Ptr& s, const CRenderizable::Ptr& r);

template <class T>
Scene::Ptr& operator << (Scene::Ptr& s, const std::vector<T>& v);

texture_name_t getNewTextureNumber(const uint8_t* optionalRgbDataForAssociation);
void releaseTextureName(const texture_name_t& t);

mrpt::serialization::CArchive& operator >> (
    mrpt::serialization::CArchive& in,
    mrpt::opengl::TLightParameters& o
    );

mrpt::serialization::CArchive& operator << (
    mrpt::serialization::CArchive& out,
    const mrpt::opengl::TLightParameters& o
    );

Viewport::Ptr& operator << (Viewport::Ptr& s, const CRenderizable::Ptr& r);
Viewport::Ptr& operator << (Viewport::Ptr& s, const std::vector<CRenderizable::Ptr>& v);

CArchive& operator << (
    CArchive& out,
    const COctoMapVoxels::TInfoPerVoxelSet& a
    );

CArchive& operator >> (
    CArchive& in,
    COctoMapVoxels::TInfoPerVoxelSet& a
    );

CArchive& operator << (
    CArchive& out,
    const COctoMapVoxels::TGridCube& a
    );

CArchive& operator >> (
    CArchive& in,
    COctoMapVoxels::TGridCube& a
    );

CArchive& operator << (
    CArchive& out,
    const COctoMapVoxels::TVoxel& a
    );

CArchive& operator >> (
    CArchive& in,
    COctoMapVoxels::TVoxel& a
    );

} // namespace opengl

Typedefs

typedef std::deque<CRenderizable::Ptr> CListOpenGLObjects

A list of smart pointers to renderizable objects.

typedef std::vector<shader_id_t> shader_list_t

A list of shader IDs.

typedef int texture_unit_t

the “i” in GL_TEXTUREi

Global Functions

void enqueueForRendering(
    const mrpt::opengl::CListOpenGLObjects& objs,
    const mrpt::opengl::TRenderMatrices& state,
    RenderQueue& rq,
    const bool skipCullChecks,
    const bool is1stShadowMapPass,
    RenderQueueStats* stats = nullptr
    )

Processes, recursively, all objects in the list, classifying them by shader programs into a list suitable to be used within processPendingRendering()

For each object in the list:

  • checks visibility of each object

  • update the MODELVIEW matrix according to its coordinates

  • call its ::render()

  • shows its name (if enabled).

Used by CSetOfObjects and Viewport

Parameters:

skipCullChecks

Will be true if the render engine already checked that the object lies within the viewport area, so it is pointless to waste more time checking.

See also:

processPendingRendering

void processRenderQueue(
    const RenderQueue& rq,
    std::map<shader_id_t, mrpt::opengl::Program::Ptr>& shaders,
    const mrpt::opengl::TLightParameters& lights,
    const std::optional<unsigned int>& depthMapTextureId = std::nullopt
    )

After enqueueForRendering(), actually executes the rendering tasks, grouped shader by shader.

Used by Viewport

template <class POSE_PDF>
CSetOfObjects::Ptr posePDF2opengl(const POSE_PDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPosePDF::getAs3DObject

mrpt::serialization::CArchive& operator >> (mrpt::serialization::CArchive& in, CPolyhedron::TPolyhedronEdge& o)

Reads a polyhedron edge from a binary stream.

mrpt::serialization::CArchive& operator << (mrpt::serialization::CArchive& out, const CPolyhedron::TPolyhedronEdge& o)

Writes a polyhedron edge to a binary stream.

mrpt::serialization::CArchive& operator >> (mrpt::serialization::CArchive& in, CPolyhedron::TPolyhedronFace& o)

Reads a polyhedron face from a binary stream.

mrpt::serialization::CArchive& operator << (mrpt::serialization::CArchive& out, const CPolyhedron::TPolyhedronFace& o)

Writes a polyhedron face to a binary stream.

template <class T>
CSetOfLines::Ptr& operator << (CSetOfLines::Ptr& l, const T& s)

Inserts a set of segments into the list.

Allows call chaining.

See also:

mrpt::opengl::CSetOfLines::appendLines

CSetOfLines::Ptr& operator << (CSetOfLines::Ptr& l, const mrpt::math::TSegment3D& s)

Inserts a segment into the list.

Allows call chaining.

See also:

mrpt::opengl::CSetOfLines::appendLine(const TSegment &)

CSetOfObjects::Ptr& operator << (CSetOfObjects::Ptr& s, const CRenderizable::Ptr& r)

Inserts an object into the list.

Allows call chaining.

See also:

mrpt::opengl::CSetOfObjects::insert

template <class T>
CSetOfObjects::Ptr& operator << (CSetOfObjects::Ptr& o, const std::vector<T>& v)

Inserts a set of objects into the list.

Allows call chaining.

See also:

mrpt::opengl::CSetOfObjects::insert

template <class T>
CSetOfTriangles::Ptr& operator << (CSetOfTriangles::Ptr& s, const T& t)

Inserts a set of triangles into the list; note that this method allows one to pass another CSetOfTriangles as argument.

Allows call chaining.

See also:

mrpt::opengl::CSetOfTriangles::insertTriangle

CSetOfTriangles::Ptr& operator << (CSetOfTriangles::Ptr& s, const mrpt::opengl::TTriangle& t)

Inserts a triangle into the list.

Allows call chaining.

See also:

mrpt::opengl::CSetOfTriangles::insertTriangle

Scene::Ptr& operator << (Scene::Ptr& s, const CRenderizable::Ptr& r)

Inserts an openGL object into a scene.

Allows call chaining.

See also:

mrpt::opengl::Scene::insert

template <class T>
Scene::Ptr& operator << (Scene::Ptr& s, const std::vector<T>& v)

Inserts any iterable collection of openGL objects into a scene, allowing call chaining.

See also:

mrpt::opengl::Scene::insert

texture_name_t getNewTextureNumber(const uint8_t* optionalRgbDataForAssociation)

Returns: [texture name, texture unit].

Viewport::Ptr& operator << (Viewport::Ptr& s, const CRenderizable::Ptr& r)

Inserts an openGL object into a viewport.

Allows call chaining.

See also:

mrpt::opengl::Viewport::insert

Viewport::Ptr& operator << (Viewport::Ptr& s, const std::vector<CRenderizable::Ptr>& v)

Inserts any iterable set of openGL objects into a viewport.

Allows call chaining.

See also:

mrpt::opengl::Viewport::insert