[mrpt-opengl]
Overview
Low-level GPU rendering: shaders, textures, framebuffers, and the rendering pipeline that draws mrpt::viz scenes.
Library mrpt-opengl
This library is part of MRPT and can be installed in Debian-based systems with:
sudo apt install libmrpt-opengl-dev
Read also how to import MRPT into your CMake scripts.
MRPT 3.0 namespace split
In MRPT 3.0 the scene-graph API (3-D objects, scenes, viewports, cameras, stock objects) moved from mrpt::opengl to mrpt::viz (library mrpt-viz). See lib_mrpt_viz_grp for the scene-graph documentation and the full list of rendering primitives.
What remains in mrpt::opengl is the low-level GPU rendering backend:
mrpt::opengl::CFBORender — off-screen framebuffer rendering
mrpt::opengl::Shader / mrpt::opengl::DefaultShaders — shader programs
mrpt::opengl::Buffer — OpenGL vertex/index buffers
mrpt::opengl::Texture — texture management
#include <mrpt/opengl/opengl_api.h>— GL function loading
User code that builds 3-D scenes should depend on mrpt_viz, not on mrpt_opengl directly. Only code that performs custom GPU rendering (e.g., off-screen rendering with CFBORender) needs mrpt_opengl.
See the full list of classes in mrpt::opengl.
Library contents
// typedefs typedef std::map<shader_id_t, std::multimap<float, RenderQueueElement>> mrpt::opengl::RenderQueue; typedef uint8_t mrpt::opengl::shader_id_t; // structs struct mrpt::opengl::CompilationStats; struct mrpt::opengl::FrameBufferBinding; struct mrpt::opengl::RenderContext; struct mrpt::opengl::RenderQueueElement; struct mrpt::opengl::RenderQueueStats; struct mrpt::viz::T2DTextData; struct mrpt::opengl::TRenderMatrices; struct mrpt::opengl::ViewportRenderStats; struct mrpt::opengl::texture_name_unit_t; // classes class mrpt::opengl::Buffer; class mrpt::opengl::CFBORender; class mrpt::opengl::CompiledScene; class mrpt::opengl::CompiledViewport; class mrpt::opengl::FrameBuffer; class mrpt::opengl::LinesProxy; class mrpt::opengl::LinesProxyBase; template <int DEPTH_LUT_NUM_BITS = 18> class mrpt::opengl::OpenGLDepth2LinearLUTs; class mrpt::opengl::PointsProxy; class mrpt::opengl::PointsProxyBase; class mrpt::opengl::Program; class mrpt::opengl::RenderableProxy; class mrpt::opengl::Shader; class mrpt::opengl::ShaderProgramManager; class mrpt::opengl::SkyBoxProxy; class mrpt::opengl::Texture; class mrpt::opengl::TexturedTrianglesProxy; class mrpt::opengl::TexturedTrianglesProxyBase; class mrpt::opengl::TrianglesProxy; class mrpt::opengl::TrianglesProxyBase; class mrpt::opengl::VertexArrayObject; // global functions Program::Ptr mrpt::opengl::LoadDefaultShader(shader_id_t id); void mrpt::opengl::registerAllClasses_mrpt_opengl(); std::tuple<double, bool, bool> mrpt::opengl::depthAndVisibleInView( const RenderableProxy* proxy, const TRenderMatrices& objState, const mrpt::poses::CPose3D& objPose, bool skipCullChecks ); std::unique_ptr<ShaderProgramManager> mrpt::opengl::createAndPreloadShaders();
Typedefs
typedef std::map<shader_id_t, std::multimap<float, RenderQueueElement>> mrpt::opengl::RenderQueue
A render queue: map from shader_id to sorted list of objects to render.
Objects are sorted by depth for correct transparency rendering. The multimap key is the depth (eye-space Z) for back-to-front ordering.
typedef uint8_t mrpt::opengl::shader_id_t
Type for IDs of shaders.
See also:
Global Functions
Program::Ptr mrpt::opengl::LoadDefaultShader(shader_id_t id)
Loads a set of OpenGL Vertex+Fragment shaders from the default library available in mrpt::opengl.
See also:
CRenderizable
void mrpt::opengl::registerAllClasses_mrpt_opengl()
Forces manual RTTI registration of all serializable classes in this namespace.
Should never be required to be explicitly called by users, except if building MRPT as a static library.
std::tuple<double, bool, bool> mrpt::opengl::depthAndVisibleInView( const RenderableProxy* proxy, const TRenderMatrices& objState, const mrpt::poses::CPose3D& objPose, bool skipCullChecks )
Computes the eye-view depth of a proxy, and whether any part of its bounding box is visible by the camera in the current state.
Parameters:
proxy |
The renderable proxy to check |
objState |
Current render matrices (for view frustum) |
objPose |
The object’s world pose |
skipCullChecks |
If true, skip frustum culling (always return visible) |
Returns:
Tuple of:
double: Depth of representative point (for sorting)
bool: visible (at least partially in view frustum)
bool: fully visible (entire bbox inside frustum)
std::unique_ptr<ShaderProgramManager> mrpt::opengl::createAndPreloadShaders()
Helper: Creates a shader program manager and preloads all default shaders.
Convenience function for initialization. Logs any compilation errors to stderr.
Example:
auto shaderMgr = createAndPreloadShaders(); // All default shaders are now ready to use
Returns:
Unique pointer to initialized manager