29 const double text_spacing = 1.5;
30 const double text_kerning = 0.1;
44 cbd.assign(vbd.size(), m_color);
45 for (
auto& tri : m_triangles) tri.setColor(m_color);
50 #if MRPT_HAS_OPENGL_GLUT 57 if (std::abs(pmv(3, 3)) < 1e-10)
return;
68 glUniformMatrix4fv(u_pmat, 1,
true, eye4.data());
74 mv(2, 3) = pmv(2, 3) / pmv(3, 3);
78 std::cerr <<
"[CText] Warning: invalid viewport size!\n";
88 mv(0, 0) *= scale / aspect;
91 glUniformMatrix4fv(u_mvmat, 1,
true, mv.data());
101 writeToStreamRender(
out);
104 out << (uint32_t)m_fontHeight << (uint32_t)m_fontWidth;
115 readFromStreamRender(in);
A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location...
const mrpt::opengl::Program * shader
virtual ~CText() override
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
const mrpt::opengl::TRenderMatrices * state
static Derived Identity()
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
The base class of 3D objects that can be directly rendered through OpenGL.
Context for calls to render()
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
mrpt::math::CMatrixFloat44 pmv_matrix
Result of p_matrix * mv_matrix.
void onUpdateBuffers_Text() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
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.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
List of lines.
Virtual base class for "archives": classes abstracting I/O streams.
size_t viewport_width
In pixels.
mrpt::vision::TStereoCalibResults out
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
The namespace for 3D scene representation and rendering.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
int uniformId(const char *name) const
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
renders glyphs as filled polygons
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
TPoint2D_< float > TPoint2Df
std::vector< mrpt::img::TColor > m_color_buffer_data