MRPT  2.0.0
gltext.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 // Stripped out version of libCVD gl-helpers.h file, ported to OpenGL>=3
11 // 2-BSD License.
12 
13 #pragma once
14 
15 #include <mrpt/math/TPoint3D.h>
16 #include <mrpt/opengl/TTriangle.h>
18 #include <mrpt/poses/CPose3D.h>
19 #include <iostream>
20 #include <map>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 namespace mrpt::opengl::internal
26 {
27 /** @name OpenGL vector 3D fonts
28  @{ */
29 
30 /// sets the font to use for future font rendering commands.
31 /// Options are: "sans", "serif", "mono".
32 /// @param fontname string containing font name
33 void glSetFont(const std::string& fontname);
34 
35 /// returns the name of the currently active font
36 const std::string& glGetFont();
37 
38 /// different style for font rendering
40 
41 /// renders a string in GL using the current settings.
42 /// Font coordinates are +X along the line and +Y along the up direction of
43 /// glyphs. The origin is at the top baseline at the left of the first
44 /// character. Characters have a maximum size of 1. linefeed is interpreted as a
45 /// new line and the start is offset in -Y direction by @ref spacing .
46 /// Individual characters are separated by @ref kerning + plus their individual
47 /// with.
48 /// @param text string to be rendered, unknown characters are replaced with '?'
49 /// @param style rendering style
50 /// @param spacing distance between individual text lines
51 /// @param kerning distance between characters
52 std::pair<double, double> glDrawText(
53  const std::string& text, std::vector<mrpt::opengl::TTriangle>& tris,
54  std::vector<mrpt::math::TPoint3Df>& lines, TEXT_STYLE style = NICE,
55  double spacing = 1.5, double kerning = 0.1);
56 
57 /// Appends to {tris,lines} the entities representing a given text including a
58 /// pose and scale transformation.
59 ///
60 /// It calls glDrawText() and appends its results to the provided buffers.
62  const std::string& text, std::vector<mrpt::opengl::TTriangle>& tris,
63  std::vector<mrpt::math::TPoint3Df>& lines,
64  std::vector<mrpt::img::TColor>& line_colors,
65  const mrpt::poses::CPose3D& text_pose, float text_scale,
66  const mrpt::img::TColor& text_color, TEXT_STYLE style = NICE,
67  double spacing = 1.5, double kerning = 0.1);
68 
69 /// returns the size of the bounding box of a text to be rendered, similar to
70 /// @ref glDrawText but without any visual output
71 std::pair<double, double> glGetExtends(
72  const std::string& text, double spacing = 1.5, double kerning = 0.1);
73 
74 /** @} */
75 
76 } // namespace mrpt::opengl::internal
const std::string & glGetFont()
returns the name of the currently active font
Definition: gltext.cpp:151
std::pair< double, double > glGetExtends(const std::string &text, double spacing, double kerning)
returns the size of the bounding box of a text to be rendered, similar to glDrawText but without any ...
Definition: gltext.cpp:233
void glDrawTextTransformed(const std::string &text, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, std::vector< mrpt::img::TColor > &line_colors, const mrpt::poses::CPose3D &text_pose, float text_scale, const mrpt::img::TColor &text_color, TEXT_STYLE style, double spacing, double kerning)
Appends to {tris,lines} the entities representing a given text including a pose and scale transformat...
Definition: gltext.cpp:268
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:19
std::pair< double, double > glDrawText(const std::string &text, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &render_lines, TEXT_STYLE style, double spacing, double kerning)
renders a string in GL using the current settings.
Definition: gltext.cpp:153
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gltext.cpp:146
This was "renders glyphs filled with antialiased outlines", but since antialiased is not properly imp...
Definition: opengl_fonts.h:27
A RGB color - 8bit.
Definition: TColor.h:25



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020