namespace mrpt::opengl::internal

Overview

namespace internal {

// typedefs

typedef TOpenGLFontStyle TEXT_STYLE;

// structs

struct Font;
struct FontData;
struct Point;
struct RenderElements;

// classes

class TexturesCache;

// global variables

static struct FontData data;
static std::list<std::shared_ptr<Program::Data>> pptc;
static std::list<std::shared_ptr<Shader::Data>> spptc;
static bool inClearPendingIfPossible = false;
static std::mutex pendingToClear_mtx;

// global functions

void glSetFont(const std::string& fontname);
const std::string& glGetFont();

std::pair<double, double> glDrawText(
    const std::string& text,
    std::vector<mrpt::opengl::TTriangle>& tris,
    std::vector<mrpt::math::TPoint3Df>& lines,
    TEXT_STYLE style = NICE,
    double spacing = 1.5,
    double kerning = 0.1
    );

std::pair<double, double> glGetExtends(
    const std::string& text,
    double spacing,
    double kerning
    );

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 = NICE,
    double spacing = 1.5,
    double kerning = 0.1
    );

void clearPendingIfPossible();

} // namespace internal

Typedefs

typedef TOpenGLFontStyle TEXT_STYLE

different style for font rendering

Global Functions

void glSetFont(const std::string& fontname)

sets the font to use for future font rendering commands.

Options are: “sans”, “serif”, “mono”.

Parameters:

fontname

string containing font name

const std::string& glGetFont()

returns the name of the currently active font

std::pair<double, double> glDrawText(
    const std::string& text,
    std::vector<mrpt::opengl::TTriangle>& tris,
    std::vector<mrpt::math::TPoint3Df>& lines,
    TEXT_STYLE 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:

text

string to be rendered, unknown characters are replaced with ‘?’

style

rendering style

spacing

distance between individual text lines

kerning

distance between characters

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 visual output

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 = NICE,
    double spacing = 1.5,
    double kerning = 0.1
    )

Appends to {tris,lines} the entities representing a given text including a pose and scale transformation.

It calls glDrawText() and appends its results to the provided buffers.