# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Member Functions | Protected Attributes

# vl::Text Class Reference

A Renderable that renders text with a given Font. More...

`#include <Text.hpp>`

Inheritance diagram for vl::Text:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| Text ()
const String & | text () const
void | setText (const String &text)
const fvec4 & | color () const
void | setColor (const fvec4 &color)
const fvec4 & | borderColor () const
void | setBorderColor (const fvec4 &border_color)
const fvec4 & | outlineColor () const
void | setOutlineColor (const fvec4 &outline_color)
const fvec4 & | backgroundColor () const
void | setBackgroundColor (const fvec4 &background_color)
const fvec4 & | shadowColor () const
void | setShadowColor (const fvec4 &shadow_color)
const fvec2 & | shadowVector () const
void | setShadowVector (const fvec2 &shadow_vector)
int | margin () const
void | setMargin (int margin)
Font * | font () const
void | setFont (Font *font)
const fmat4 | matrix () const
void | setMatrix (const fmat4 &matrix)
int | alignment () const
void | setAlignment (int align)
int | viewportAlignment () const
void | setViewportAlignment (int align)
float | interlineSpacing () const
void | setInterlineSpacing (float spacing)
ETextMode | mode () const
void | setMode (ETextMode mode)
ETextLayout | layout () const
void | setLayout (ETextLayout layout)
ETextAlign | textAlignment () const
void | setTextAlignment (ETextAlign align)
bool | borderEnabled () const
void | setBorderEnabled (bool border)
bool | backgroundEnabled () const
void | setBackgroundEnabled (bool background)
bool | kerningEnabled () const
void | setKerningEnabled (bool kerning)
bool | outlineEnabled () const
void | setOutlineEnabled (bool outline)
bool | shadowEnabled () const
void | setShadowEnabled (bool shadow)
virtual void | render_Implementation (const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context) const
void | computeBounds_Implementation ()
AABB | boundingRect () const
| Returns the plain 2D bounding box of the text, without taking into consideration the Text's matrix transform and the eventual actor's transform.
AABB | boundingRect (const String &text) const
AABB | boundingRectTransformed (vec3 &a, vec3 &b, vec3 &c, vec3 &d, const Camera *camera, const Actor *actor=NULL) const
AABB | boundingRectTransformed (const Camera *camera, const Actor *actor=NULL) const
| Returns the fully transformed bounding box.
void | translate (float x, float y, float z)
void | rotate (float degrees, float x, float y, float z)
void | resetMatrix ()
void | updateVBOs (bool, bool)
| Uploads the data stored in the local buffers on the GPU memory.

## Protected Member Functions

void | renderText (const Actor *, const Camera *camera, const fvec4 &color, const fvec2 &offset) const
void | renderBackground (const Actor *actor, const Camera *camera) const
void | renderBorder (const Actor *actor, const Camera *camera) const
AABB | rawboundingRect (const String &text) const

## Protected Attributes

ref< Font > | mFont
String | mText
fvec4 | mColor
fvec4 | mBorderColor
fvec4 | mBackgroundColor
fvec4 | mOutlineColor
fvec4 | mShadowColor
fvec2 | mShadowVector
fmat4 | mMatrix
float | mInterlineSpacing
int | mAlignment
int | mViewportAlignment
int | mMargin
ETextMode | mMode
ETextLayout | mLayout
ETextAlign | mTextAlignment
bool | mBorderEnabled
bool | mBackgroundEnabled
bool | mOutlineEnabled
bool | mShadowEnabled
bool | mKerningEnabled

## Detailed Description

A Renderable that renders text with a given Font.

See also:
  - Actor
  - VectorGraphics

Definition at line 50 of file Text.hpp.

## Constructor & Destructor Documentation

vl::Text::Text | ( | ) | `[inline]`

Definition at line 54 of file Text.hpp.

References VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::Text::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Renderable.

Definition at line 53 of file Text.hpp.

const String& vl::Text::text | ( | ) | const`[inline]`

Definition at line 61 of file Text.hpp.

Referenced by boundingRect(), render_Implementation(), and renderText().

void vl::Text::setText | ( | const String & | text ) | `[inline]`

Definition at line 62 of file Text.hpp.

const fvec4& vl::Text::color | ( | ) | const`[inline]`

Definition at line 64 of file Text.hpp.

Referenced by render_Implementation(), and renderText().

void vl::Text::setColor | ( | const fvec4 & | color ) | `[inline]`

Definition at line 65 of file Text.hpp.

Referenced by vl::VolumePlot::VolumePlot().

const fvec4& vl::Text::borderColor | ( | ) | const`[inline]`

Definition at line 67 of file Text.hpp.

void vl::Text::setBorderColor | ( | const fvec4 & | border_color ) | `[inline]`

Definition at line 68 of file Text.hpp.

const fvec4& vl::Text::outlineColor | ( | ) | const`[inline]`

Definition at line 70 of file Text.hpp.

Referenced by render_Implementation().

void vl::Text::setOutlineColor | ( | const fvec4 & | outline_color ) | `[inline]`

Definition at line 71 of file Text.hpp.

const fvec4& vl::Text::backgroundColor | ( | ) | const`[inline]`

Definition at line 73 of file Text.hpp.

void vl::Text::setBackgroundColor | ( | const fvec4 & | background_color ) | `[inline]`

Definition at line 74 of file Text.hpp.

const fvec4& vl::Text::shadowColor | ( | ) | const`[inline]`

Definition at line 76 of file Text.hpp.

Referenced by render_Implementation().

void vl::Text::setShadowColor | ( | const fvec4 & | shadow_color ) | `[inline]`

Definition at line 77 of file Text.hpp.

const fvec2& vl::Text::shadowVector | ( | ) | const`[inline]`

Definition at line 79 of file Text.hpp.

Referenced by render_Implementation().

void vl::Text::setShadowVector | ( | const fvec2 & | shadow_vector ) | `[inline]`

Definition at line 80 of file Text.hpp.

int vl::Text::margin | ( | ) | const`[inline]`

Definition at line 82 of file Text.hpp.

Referenced by boundingRect(), rawboundingRect(), and renderText().

void vl::Text::setMargin | ( | int | margin ) | `[inline]`

Definition at line 83 of file Text.hpp.

Font* vl::Text::font | ( | ) | const`[inline]`

Definition at line 85 of file Text.hpp.

Referenced by vl::VectorGraphics::drawText(), rawboundingRect(), render_Implementation(), and renderText().

void vl::Text::setFont | ( | Font * | font ) | `[inline]`

Definition at line 86 of file Text.hpp.

Referenced by vl::VectorGraphics::drawText().

const fmat4 vl::Text::matrix | ( | ) | const`[inline]`

Definition at line 88 of file Text.hpp.

void vl::Text::setMatrix | ( | const fmat4 & | matrix ) | `[inline]`

Definition at line 89 of file Text.hpp.

int vl::Text::alignment | ( | ) | const`[inline]`

Definition at line 91 of file Text.hpp.

Referenced by boundingRect(), and renderText().

void vl::Text::setAlignment | ( | int | align ) | `[inline]`

Definition at line 92 of file Text.hpp.

int vl::Text::viewportAlignment | ( | ) | const`[inline]`

Definition at line 94 of file Text.hpp.

Referenced by boundingRectTransformed(), and renderText().

void vl::Text::setViewportAlignment | ( | int | align ) | `[inline]`

Definition at line 95 of file Text.hpp.

float vl::Text::interlineSpacing | ( | ) | const`[inline]`

Definition at line 97 of file Text.hpp.

void vl::Text::setInterlineSpacing | ( | float | spacing ) | `[inline]`

Definition at line 98 of file Text.hpp.

ETextMode vl::Text::mode | ( | ) | const`[inline]`

Definition at line 100 of file Text.hpp.

Referenced by boundingRectTransformed(), render_Implementation(), renderBackground(), renderBorder(), and renderText().

void vl::Text::setMode | ( | ETextMode | mode ) | `[inline]`

Definition at line 101 of file Text.hpp.

ETextLayout vl::Text::layout | ( | ) | const`[inline]`

Definition at line 103 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

void vl::Text::setLayout | ( | ETextLayout | layout ) | `[inline]`

Definition at line 104 of file Text.hpp.

ETextAlign vl::Text::textAlignment | ( | ) | const`[inline]`

Definition at line 106 of file Text.hpp.

Referenced by renderText().

void vl::Text::setTextAlignment | ( | ETextAlign | align ) | `[inline]`

Definition at line 107 of file Text.hpp.

bool vl::Text::borderEnabled | ( | ) | const`[inline]`

Definition at line 109 of file Text.hpp.

Referenced by boundingRect(), render_Implementation(), and renderText().

void vl::Text::setBorderEnabled | ( | bool | border ) | `[inline]`

Definition at line 110 of file Text.hpp.

bool vl::Text::backgroundEnabled | ( | ) | const`[inline]`

Definition at line 112 of file Text.hpp.

Referenced by boundingRect(), render_Implementation(), and renderText().

void vl::Text::setBackgroundEnabled | ( | bool | background ) | `[inline]`

Definition at line 113 of file Text.hpp.

bool vl::Text::kerningEnabled | ( | ) | const`[inline]`

Definition at line 115 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

void vl::Text::setKerningEnabled | ( | bool | kerning ) | `[inline]`

Definition at line 116 of file Text.hpp.

bool vl::Text::outlineEnabled | ( | ) | const`[inline]`

Definition at line 118 of file Text.hpp.

Referenced by render_Implementation().

void vl::Text::setOutlineEnabled | ( | bool | outline ) | `[inline]`

Definition at line 119 of file Text.hpp.

bool vl::Text::shadowEnabled | ( | ) | const`[inline]`

Definition at line 121 of file Text.hpp.

Referenced by render_Implementation().

void vl::Text::setShadowEnabled | ( | bool | shadow ) | `[inline]`

Definition at line 122 of file Text.hpp.

void Text::render_Implementation | ( | const Actor * | actor,
|  | const Shader * | shader,
|  | const Camera * | camera,
|  | OpenGLContext * | gl_context
| ) |  | const`[virtual]`

Implements vl::Renderable.

Definition at line 43 of file Text.cpp.

References backgroundEnabled(), vl::OpenGLContext::bindVAS(), borderEnabled(), color(), font(), mode(), outlineColor(), outlineEnabled(), renderBackground(), renderBorder(), renderText(), shadowColor(), shadowEnabled(), shadowVector(), text(), vl::Text2D, and VL_CHECK.

void vl::Text::computeBounds_Implementation | ( | ) | `[inline, virtual]`

Implements vl::Renderable.

Definition at line 125 of file Text.hpp.

AABB Text::boundingRect | ( | ) | const

Returns the plain 2D bounding box of the text, without taking into consideration the Text's matrix transform and the eventual actor's transform.

Definition at line 807 of file Text.cpp.

References text().

Referenced by boundingRectTransformed().

AABB Text::boundingRect | ( | const String & | text ) | const

Definition at line 812 of file Text.cpp.

References vl::AlignBottom, vl::AlignHCenter, vl::AlignLeft, alignment(), vl::AlignRight, vl::AlignTop, vl::AlignVCenter, backgroundEnabled(), borderEnabled(), vl::AABB::height(), margin(), vl::max(), vl::AABB::maxCorner(), vl::min(), vl::AABB::minCorner(), rawboundingRect(), vl::AABB::setMaxCorner(), vl::AABB::setMinCorner(), VL_CHECK, vl::AABB::width(), vl::Vector3< T_Scalar >::x(), and vl::Vector3< T_Scalar >::y().

AABB Text::boundingRectTransformed | ( | vec3 & | a,
|  | vec3 & | b,
|  | vec3 & | c,
|  | vec3 & | d,
|  | const Camera * | camera,
|  | const Actor * | actor = `NULL`
| ) |  | const

Definition at line 889 of file Text.cpp.

References vl::AABB::addPoint(), vl::AlignBottom, vl::AlignHCenter, vl::AlignLeft, vl::AlignRight, vl::AlignTop, vl::AlignVCenter, boundingRect(), vl::Viewport::height(), vl::AABB::maxCorner(), vl::AABB::minCorner(), mMatrix, mode(), vl::Camera::project(), vl::AABB::setNull(), vl::Text2D, vl::Text3D, vl::Actor::transform(), vl::Matrix4< T_Scalar >::translate(), vl::Camera::viewport(), viewportAlignment(), VL_CHECK, vl::Viewport::width(), vl::ITransform::worldMatrix(), vl::Vector4< T_Scalar >::x(), vl::Viewport::x(), vl::Vector3< T_Scalar >::x(), vl::Vector4< T_Scalar >::xyz(), vl::Vector4< T_Scalar >::y(), vl::Viewport::y(), vl::Vector3< T_Scalar >::y(), vl::Vector4< T_Scalar >::z(), and vl::Vector3< T_Scalar >::z().

Referenced by boundingRectTransformed(), renderBackground(), and renderBorder().

AABB Text::boundingRectTransformed | ( | const Camera * | camera,
|  | const Actor * | actor = `NULL`
| ) |  | const

Returns the fully transformed bounding box.

`actor` is needed only if you are using the actor's transform with the Text2D to make the Text2D text follow the actor on the screen or you are using the Text3D to make the text follow the actor's transform in 3D.

The layout of the a, b, c and d points is the following:
d---------c
| |
| |
a---------b
Of course the above layout can be scaled, flipped, rotated and so on according to the given Text's matrix.

Definition at line 883 of file Text.cpp.

References boundingRectTransformed().

void Text::translate | ( | float | x,
|  | float | y,
|  | float | z
| ) |  |

Definition at line 1003 of file Text.cpp.

References mMatrix, and vl::Matrix4< T_Scalar >::translate().

void Text::rotate | ( | float | degrees,
|  | float | x,
|  | float | y,
|  | float | z
| ) |  |

Definition at line 1008 of file Text.cpp.

References mMatrix, and vl::Matrix4< T_Scalar >::rotate().

void Text::resetMatrix | ( | ) |

Definition at line 1013 of file Text.cpp.

References mMatrix, and vl::Matrix4< T_Scalar >::setIdentity().

void vl::Text::updateVBOs | ( | bool | discard_local_data,
|  | bool | force_update
| ) |  | `[inline, virtual]`

Uploads the data stored in the local buffers on the GPU memory.

If 'discard_local_data' is set to `true` the memory used by the local buffers is released.

Implements vl::Renderable.

Definition at line 137 of file Text.hpp.

void Text::renderText | ( | const Actor * | actor,
|  | const Camera * | camera,
|  | const fvec4 & | color,
|  | const fvec2 & | offset
| ) |  | const`[protected]`

Definition at line 136 of file Text.cpp.

References vl::AlignBottom, vl::AlignHCenter, vl::AlignLeft, alignment(), vl::AlignRight, vl::AlignTop, vl::AlignVCenter, backgroundEnabled(), borderEnabled(), color(), vl::Matrix4< T_Scalar >::e(), vl::Log::error(), font(), vl::Matrix4< GLdouble >::getOrtho(), vl::Viewport::height(), kerningEnabled(), layout(), vl::LeftToRightText, vl::String::length(), vl::length(), margin(), vl::AABB::maxCorner(), mFont, vl::AABB::minCorner(), mMatrix, mode(), vl::Camera::project(), vl::Matrix4< T_Scalar >::ptr(), rawboundingRect(), vl::RightToLeftText, text(), vl::Text2D, vl::TextAlignCenter, vl::TextAlignJustify, vl::TextAlignLeft, textAlignment(), vl::TextAlignRight, vl::Actor::transform(), vl::Matrix4< T_Scalar >::translate(), vl::Camera::viewport(), viewportAlignment(), VL_CHECK, VL_CHECK_OGL, vl::VL_glActiveTexture(), vl::VL_glClientActiveTexture(), VL_TRAP, vl::AABB::width(), vl::Viewport::width(), vl::ITransform::worldMatrix(), vl::Vector4< T_Scalar >::x(), vl::Vector2< T_Scalar >::x(), vl::Vector3< T_Scalar >::x(), vl::Viewport::x(), vl::Vector4< T_Scalar >::y(), vl::Vector2< T_Scalar >::y(), vl::Vector3< T_Scalar >::y(), vl::Viewport::y(), vl::Vector4< T_Scalar >::z(), and vl::Vector3< T_Scalar >::z().

Referenced by render_Implementation().

void Text::renderBackground | ( | const Actor * | actor,
|  | const Camera * | camera
| ) |  | const`[protected]`

Definition at line 693 of file Text.cpp.

References boundingRectTransformed(), vl::Matrix4< T_Scalar >::e(), vl::Matrix4< GLdouble >::getOrtho(), vl::Viewport::height(), mBackgroundColor, mode(), vl::Matrix4< T_Scalar >::ptr(), vl::Text2D, vl::Camera::viewport(), VL_CHECK_OGL, vl::Viewport::width(), vl::Viewport::x(), and vl::Viewport::y().

Referenced by render_Implementation().

void Text::renderBorder | ( | const Actor * | actor,
|  | const Camera * | camera
| ) |  | const`[protected]`

Definition at line 749 of file Text.cpp.

References boundingRectTransformed(), vl::Matrix4< T_Scalar >::e(), vl::Matrix4< GLdouble >::getOrtho(), vl::Viewport::height(), mBorderColor, mode(), vl::Matrix4< T_Scalar >::ptr(), vl::Text2D, vl::Camera::viewport(), VL_CHECK_OGL, vl::Viewport::width(), vl::Viewport::x(), and vl::Viewport::y().

Referenced by render_Implementation().

AABB Text::rawboundingRect | ( | const String & | text ) | const`[protected]`

Definition at line 564 of file Text.cpp.

References vl::AABB::addPoint(), vl::Log::error(), font(), vl::ref< T >::get(), kerningEnabled(), layout(), vl::LeftToRightText, vl::String::length(), margin(), mFont, vl::RightToLeftText, VL_TRAP, vl::Vector3< T_Scalar >::x(), vl::Vector2< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector2< T_Scalar >::y().

Referenced by boundingRect(), and renderText().

## Member Data Documentation

ref<Font> vl::Text::mFont`[protected]`

Definition at line 146 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

String vl::Text::mText`[protected]`

Definition at line 147 of file Text.hpp.

fvec4 vl::Text::mColor`[protected]`

Definition at line 148 of file Text.hpp.

fvec4 vl::Text::mBorderColor`[protected]`

Definition at line 149 of file Text.hpp.

Referenced by renderBorder().

fvec4 vl::Text::mBackgroundColor`[protected]`

Definition at line 150 of file Text.hpp.

Referenced by renderBackground().

fvec4 vl::Text::mOutlineColor`[protected]`

Definition at line 151 of file Text.hpp.

fvec4 vl::Text::mShadowColor`[protected]`

Definition at line 152 of file Text.hpp.

fvec2 vl::Text::mShadowVector`[protected]`

Definition at line 153 of file Text.hpp.

fmat4 vl::Text::mMatrix`[protected]`

Definition at line 154 of file Text.hpp.

Referenced by boundingRectTransformed(), renderText(), resetMatrix(), rotate(), and translate().

float vl::Text::mInterlineSpacing`[protected]`

Definition at line 155 of file Text.hpp.

int vl::Text::mAlignment`[protected]`

Definition at line 156 of file Text.hpp.

int vl::Text::mViewportAlignment`[protected]`

Definition at line 157 of file Text.hpp.

int vl::Text::mMargin`[protected]`

Definition at line 158 of file Text.hpp.

ETextMode vl::Text::mMode`[protected]`

Definition at line 159 of file Text.hpp.

ETextLayout vl::Text::mLayout`[protected]`

Definition at line 160 of file Text.hpp.

ETextAlign vl::Text::mTextAlignment`[protected]`

Definition at line 161 of file Text.hpp.

bool vl::Text::mBorderEnabled`[protected]`

Definition at line 162 of file Text.hpp.

bool vl::Text::mBackgroundEnabled`[protected]`

Definition at line 163 of file Text.hpp.

bool vl::Text::mOutlineEnabled`[protected]`

Definition at line 164 of file Text.hpp.

bool vl::Text::mShadowEnabled`[protected]`

Definition at line 165 of file Text.hpp.

bool vl::Text::mKerningEnabled`[protected]`

Definition at line 166 of file Text.hpp.

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Text.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Text.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:46.
Permission is granted to use this page to write and publish articles regarding Visualization Library.