Main MRPT website > C++ reference for MRPT 1.4.0
Classes
mrpt::opengl::gl_utils Namespace Reference

Detailed Description

A set of auxiliary functions that can be called to render OpenGL primitives from MRPT or user code.

Classes

struct  TRenderInfo
 Information about the rendering process being issued. More...
 

Function Documentation

◆ checkOpenGLError()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::checkOpenGLError ( )

Checks glGetError and throws an exception if an error situation is found.

◆ getCurrentRenderingInfo()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::getCurrentRenderingInfo ( TRenderInfo ri)

Gather useful information on the render parameters.

It can be called from within the render() method of CRenderizable-derived classes, and the returned matrices can be used to determine whether a given point (lx,ly,lz) in local coordinates wrt the object being rendered falls within the screen or not:

TRenderInfo ri;
Eigen::Matrix<float,4,4> M= ri.proj_matrix * ri.model_matrix * HomogeneousMatrix(lx,ly,lz);
const float rend_x = M(0,3)/M(3,3);
const float rend_y = M(1,3)/M(3,3);

where (rend_x,rend_y) are both in the range [-1,1].

◆ glDrawText()

mrpt::utils::TPixelCoordf OPENGL_IMPEXP mrpt::opengl::gl_utils::glDrawText ( const std::string &  text,
const double  textScale,
enum TOpenGLFontStyle  style = NICE,
double  spacing = 1.5,
double  kerning = 0.1 
)

renders a string in GL using the current settings.

Font coordinates are +X along the line and +Y along the up direction of glyphs. The origin is at the top baseline at the left of the first character. Characters have a maximum size of 1. linefeed is interpreted as a new line and the start is offset in -Y direction by spacing . Individual characters are separated by kerning + plus their individual with.

Parameters
textstring to be rendered, unknown characters are replaced with '?'
textScaleThe size of the characters (default=1.0)
stylerendering style
spacingdistance between individual text lines
kerningdistance between characters
Note
This functions comes from libcvd (LGPL, http://www.edwardrosten.com/cvd/ )

◆ glGetExtends()

mrpt::utils::TPixelCoordf OPENGL_IMPEXP mrpt::opengl::gl_utils::glGetExtends ( const std::string &  text,
const double  textScale,
double  spacing = 1.5,
double  kerning = 0.1 
)

returns the size of the bounding box of a text to be rendered, similar to glDrawText but without any visual output

Note
This functions comes from libcvd (LGPL, http://www.edwardrosten.com/cvd/ )

◆ glGetFont()

const OPENGL_IMPEXP std::string& mrpt::opengl::gl_utils::glGetFont ( )

returns the name of the currently active font

◆ glSetFont()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::glSetFont ( const std::string &  fontname)

sets the font to use for future font rendering commands.

currently "sans", "serif" and "mono" are available.

Parameters
fontnamestring containing font name

◆ renderMessageBox()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderMessageBox ( const float  msg_x,
const float  msg_y,
const float  msg_w,
const float  msg_h,
const std::string &  text,
float  text_scale,
const mrpt::utils::TColor back_col = mrpt::utils::TColor(0, 0, 50, 150),
const mrpt::utils::TColor border_col = mrpt::utils::TColor(0, 0, 0, 140),
const mrpt::utils::TColor text_col = mrpt::utils::TColor(255, 255, 255, 220),
const float  border_width = 4.0f,
const std::string &  text_font = std::string("sans"),
mrpt::opengl::TOpenGLFontStyle  text_style = mrpt::opengl::FILL,
const double  text_spacing = 1.5,
const double  text_kerning = 0.1 
)

Draws a message box with a centered (possibly multi-lined) text.

It consists of a filled rectangle with a frame around and the centered text in the middle.

The appearance of the box is highly configurable via parameters.

Parameters
[in]msg_x,msg_yThe left-lower corner coordinates, in ratio [0,1] of the viewport size. (0,0) if the left-bottom corner of the viewport.
[in]msg_w,msg_hThe width & height, in ratio [0,1] of the viewport size.
[in]textThe text to display. Multiple lines can be drawn with the '
' character.
[in]text_scaleSize of characters, in ration [0,1] of the viewport size. Note that this size may be scaled automatically reduced to fit the text withtin the rectangle of the message box.
[in]back_colColor of the rectangle background. Alpha can be <255 to enable transparency.
[in]border_colColor of the rectangle frame. Alpha can be <255 to enable transparency.
[in]text_colColor of the text background. Alpha can be <255 to enable transparency.
[in]border_widthWidth of the border, in pixels
[in]text_font,text_style,text_spacing,text_kerningSee mrpt::opengl::gl_utils::glDrawText()

Example (see directory: 'samples/display3D_custom_render'):

◆ renderQuadWithNormal()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderQuadWithNormal ( const mrpt::math::TPoint3Df p1,
const mrpt::math::TPoint3Df p2,
const mrpt::math::TPoint3Df p3,
const mrpt::math::TPoint3Df p4 
)

Can be used by derived classes to draw a quad with a normal vector computed automatically - to be called within a glBegin()-glEnd() block.

◆ renderSetOfObjects()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderSetOfObjects ( const mrpt::opengl::CListOpenGLObjects objs)

For each object in the list:

  • checks visibility of each object
  • prepare the GL_MODELVIEW matrix according to its coordinates
  • call its ::render()
  • shows its name (if enabled).
Note
Used by COpenGLViewport, CSetOfObjects

◆ renderTextBitmap()

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderTextBitmap ( const char *  str,
void *  fontStyle 
)

This method is safe for calling from within ::render() methods.

See also
renderTextBitmap

◆ renderTriangleWithNormal() [1/2]

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderTriangleWithNormal ( const mrpt::math::TPoint3D p1,
const mrpt::math::TPoint3D p2,
const mrpt::math::TPoint3D p3 
)

Can be used by derived classes to draw a triangle with a normal vector computed automatically - to be called within a glBegin()-glEnd() block.

◆ renderTriangleWithNormal() [2/2]

void OPENGL_IMPEXP mrpt::opengl::gl_utils::renderTriangleWithNormal ( const mrpt::math::TPoint3Df p1,
const mrpt::math::TPoint3Df p2,
const mrpt::math::TPoint3Df p3 
)

◆ textBitmapWidth()

int OPENGL_IMPEXP mrpt::opengl::gl_utils::textBitmapWidth ( const std::string &  str,
mrpt::opengl::TOpenGLFont  font = mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24 
)

Return the exact width in pixels for a given string, as will be rendered by renderTextBitmap().

See also
renderTextBitmap
mrpt::opengl::gl_utils::getCurrentRenderingInfo
void OPENGL_IMPEXP getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.



Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Tue Mar 3 09:15:16 UTC 2020