25 void CTextMessageCapable::render_text_messages(
const int w,
const int h)
const
27 #if MRPT_HAS_OPENGL_GLUT
29 GLint old_matMode = 0;
45 const int x = it->second.x>=1 ? int(it->second.x) : (it->second.x<0 ? int(
w+it->second.x) : int(it->second.x *
w));
46 const int y = it->second.y>=1 ? int(it->second.y) : (it->second.y<0 ? int(h+it->second.y) : int(it->second.y * h));
50 string font_name=
"sans";
52 double font_spacing = 1.5;
53 double font_kerning = 0.1;
55 switch(it->second.font)
65 font_size = it->second.vfont_scale;
66 font_name = it->second.vfont_name;
67 font_style = it->second.vfont_style;
68 font_spacing = it->second.vfont_spacing;
69 font_kerning = it->second.vfont_kerning;
73 std::cerr <<
"[CTextMessageCapable::render_text_messages] Invalid value for TOpenGLFont\n";
77 if (it->second.draw_shadow)
83 glColor3f(it->second.shadow_color.R,it->second.shadow_color.G,it->second.shadow_color.B);
94 glColor3f(it->second.color.R,it->second.color.G,it->second.color.B);
114 void CTextMessageCapable::clearTextMessages()
120 void CTextMessageCapable::addTextMessage(
125 const size_t unique_index ,
136 m_2D_texts[unique_index] = d;
142 bool CTextMessageCapable::updateTextMessage(
const size_t unique_index,
const std::string &text)
145 if (it == m_2D_texts.end())
149 it->second.text = text;
156 void CTextMessageCapable::addTextMessage(
162 const double font_size,
164 const size_t unique_index,
165 const double font_spacing,
166 const double font_kerning,
167 const bool has_shadow,
185 m_2D_texts[unique_index] = d;
const Scalar * const_iterator
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
GLAPI void GLAPIENTRY glPushMatrix(void)
GLAPI void GLAPIENTRY glLoadIdentity(void)
GLAPI void GLAPIENTRY glPopMatrix(void)
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLchar ** string
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
@ MRPT_GLUT_BITMAP_TIMES_ROMAN_24
@ MRPT_GLUT_BITMAP_HELVETICA_18
@ MRPT_GLUT_BITMAP_HELVETICA_12
@ MRPT_GLUT_BITMAP_HELVETICA_10
@ MRPT_GLUT_BITMAP_TIMES_ROMAN_10
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void OPENGL_IMPEXP glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
mrpt::utils::TPixelCoordf OPENGL_IMPEXP 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.
The namespace for 3D scene representation and rendering.
TOpenGLFontStyle
Different style for vectorized font rendering.
@ FILL
renders glyphs as filled polygons
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
An auxiliary struct for holding a list of text messages in some mrpt::opengl & mrpt::gui classes The ...
mrpt::opengl::TOpenGLFont font
TOpenGLFontStyle vfont_style
(default: NICE) See TOpenGLFontStyle.
std::string vfont_name
Vectorized font name ("sans","mono","serif")
double vfont_scale
Size of characters.
double vfont_kerning
(default: 0.1) Refer to mrpt::opengl::gl_utils::glDrawText
double vfont_spacing
(default: 1.5) Refer to mrpt::opengl::gl_utils::glDrawText
mrpt::utils::TColorf color
mrpt::utils::TColorf shadow_color
A RGB color - floats in the range [0,1].