25 void CTextMessageCapable::render_text_messages(
const int w,
const int h)
const 27 #if MRPT_HAS_OPENGL_GLUT 29 GLint old_matMode = 0;
42 for (
const auto& m_2D_text : m_2D_texts)
47 m_2D_text.second.x >= 1
48 ? int(m_2D_text.second.x)
49 : (m_2D_text.second.x < 0 ? int(
w + m_2D_text.second.x)
50 : int(m_2D_text.second.x *
w));
52 m_2D_text.second.y >= 1
53 ? int(m_2D_text.second.y)
54 : (m_2D_text.second.y < 0 ? int(h + m_2D_text.second.y)
55 : int(m_2D_text.second.y * h));
58 double font_size = 10;
59 string font_name =
"sans";
61 double font_spacing = 1.5;
62 double font_kerning = 0.1;
64 switch (m_2D_text.second.font)
90 font_size = m_2D_text.second.vfont_scale;
91 font_name = m_2D_text.second.vfont_name;
92 font_style = m_2D_text.second.vfont_style;
93 font_spacing = m_2D_text.second.vfont_spacing;
94 font_kerning = m_2D_text.second.vfont_kerning;
98 std::cerr <<
"[CTextMessageCapable::render_text_messages] " 99 "Invalid value for TOpenGLFont\n";
103 if (m_2D_text.second.draw_shadow)
110 m_2D_text.second.shadow_color.R,
111 m_2D_text.second.shadow_color.G,
112 m_2D_text.second.shadow_color.B);
115 m_2D_text.second.text, font_size, font_style, font_spacing,
126 m_2D_text.second.color.R, m_2D_text.second.color.G,
127 m_2D_text.second.color.B);
130 m_2D_text.second.text, font_size, font_style, font_spacing,
149 void CTextMessageCapable::clearTextMessages() { m_2D_texts.clear(); }
150 void CTextMessageCapable::addTextMessage(
151 const double x_frac,
const double y_frac,
const std::string& text,
162 m_2D_texts[unique_index] = d;
169 bool CTextMessageCapable::updateTextMessage(
170 const size_t unique_index,
const std::string& text)
172 auto it = m_2D_texts.find(unique_index);
173 if (it == m_2D_texts.end())
177 it->second.
text = text;
184 void CTextMessageCapable::addTextMessage(
185 const double x_frac,
const double y_frac,
const std::string& text,
188 const size_t unique_index,
const double font_spacing,
189 const double font_kerning,
const bool has_shadow,
206 m_2D_texts[unique_index] = d;
mrpt::opengl::TOpenGLFont font
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPopMatrix(void)
mrpt::img::TPixelCoordf 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.
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
GLAPI void GLAPIENTRY glLoadIdentity(void)
GLubyte GLubyte GLubyte GLubyte w
std::string vfont_name
Vectorized font name ("sans","mono","serif")
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
TOpenGLFontStyle
Different style for vectorized font rendering.
double vfont_kerning
(default: 0.1) Refer to mrpt::opengl::gl_utils::glDrawText
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
An auxiliary struct for holding a list of text messages in some mrpt::opengl & mrpt::gui classes The ...
GLsizei const GLchar ** string
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double vfont_spacing
(default: 1.5) Refer to mrpt::opengl::gl_utils::glDrawText
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
A RGB color - floats in the range [0,1].
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
GLAPI void GLAPIENTRY glPushMatrix(void)
renders glyphs as filled polygons
GLAPI void GLAPIENTRY glDisable(GLenum cap)
mrpt::img::TColorf shadow_color
double vfont_scale
Size of characters.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
TOpenGLFontStyle vfont_style
(default: NICE) See TOpenGLFontStyle.