Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
A Renderable that renders text with a given Font. More...
#include <Text.hpp>
Public Member Functions | |
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) |
const Font * | font () const |
Font * | font () |
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 () |
virtual void | updateDirtyBufferObject (EBufferObjectUpdateMode) |
Uploads the data stored in the local buffers on the GPU memory. | |
virtual void | deleteBufferObject () |
Destroys the BufferObject (vertex buffer objects) associated to this a Renderable. | |
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 |
A Renderable that renders text with a given Font.
Definition at line 50 of file Text.hpp.
vl::Text::Text | ( | ) | [inline] |
Definition at line 55 of file Text.hpp.
References VL_DEBUG_SET_OBJECT_NAME.
const String& vl::Text::text | ( | ) | const [inline] |
Definition at line 62 of file Text.hpp.
Referenced by boundingRect(), render_Implementation(), and renderText().
const fvec4& vl::Text::color | ( | ) | const [inline] |
Definition at line 65 of file Text.hpp.
Referenced by render_Implementation().
void vl::Text::setColor | ( | const fvec4 & | color ) | [inline] |
Definition at line 66 of file Text.hpp.
Referenced by vl::VolumePlot::VolumePlot().
void vl::Text::setBorderColor | ( | const fvec4 & | border_color ) | [inline] |
const fvec4& vl::Text::outlineColor | ( | ) | const [inline] |
Definition at line 71 of file Text.hpp.
Referenced by render_Implementation().
void vl::Text::setOutlineColor | ( | const fvec4 & | outline_color ) | [inline] |
void vl::Text::setBackgroundColor | ( | const fvec4 & | background_color ) | [inline] |
const fvec4& vl::Text::shadowColor | ( | ) | const [inline] |
Definition at line 77 of file Text.hpp.
Referenced by render_Implementation().
void vl::Text::setShadowColor | ( | const fvec4 & | shadow_color ) | [inline] |
const fvec2& vl::Text::shadowVector | ( | ) | const [inline] |
Definition at line 80 of file Text.hpp.
Referenced by render_Implementation().
void vl::Text::setShadowVector | ( | const fvec2 & | shadow_vector ) | [inline] |
int vl::Text::margin | ( | ) | const [inline] |
Definition at line 83 of file Text.hpp.
Referenced by boundingRect(), rawboundingRect(), and renderText().
const Font* vl::Text::font | ( | ) | const [inline] |
Definition at line 86 of file Text.hpp.
Referenced by vl::VectorGraphics::drawText(), rawboundingRect(), render_Implementation(), and renderText().
void vl::Text::setFont | ( | Font * | font ) | [inline] |
Definition at line 88 of file Text.hpp.
Referenced by vl::VectorGraphics::drawText().
int vl::Text::alignment | ( | ) | const [inline] |
Definition at line 93 of file Text.hpp.
Referenced by boundingRect(), and renderText().
int vl::Text::viewportAlignment | ( | ) | const [inline] |
Definition at line 96 of file Text.hpp.
Referenced by boundingRectTransformed(), and renderText().
void vl::Text::setInterlineSpacing | ( | float | spacing ) | [inline] |
ETextMode vl::Text::mode | ( | ) | const [inline] |
Definition at line 102 of file Text.hpp.
Referenced by boundingRectTransformed(), renderBackground(), renderBorder(), and renderText().
ETextLayout vl::Text::layout | ( | ) | const [inline] |
Definition at line 105 of file Text.hpp.
Referenced by rawboundingRect(), and renderText().
void vl::Text::setLayout | ( | ETextLayout | layout ) | [inline] |
ETextAlign vl::Text::textAlignment | ( | ) | const [inline] |
Definition at line 108 of file Text.hpp.
Referenced by renderText().
void vl::Text::setTextAlignment | ( | ETextAlign | align ) | [inline] |
bool vl::Text::borderEnabled | ( | ) | const [inline] |
Definition at line 111 of file Text.hpp.
Referenced by boundingRect(), render_Implementation(), and renderText().
bool vl::Text::backgroundEnabled | ( | ) | const [inline] |
Definition at line 114 of file Text.hpp.
Referenced by boundingRect(), render_Implementation(), and renderText().
void vl::Text::setBackgroundEnabled | ( | bool | background ) | [inline] |
bool vl::Text::kerningEnabled | ( | ) | const [inline] |
Definition at line 117 of file Text.hpp.
Referenced by rawboundingRect(), and renderText().
bool vl::Text::outlineEnabled | ( | ) | const [inline] |
Definition at line 120 of file Text.hpp.
Referenced by render_Implementation().
bool vl::Text::shadowEnabled | ( | ) | const [inline] |
Definition at line 123 of file Text.hpp.
Referenced by render_Implementation().
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(), vl::OpenGLContext::color(), color(), font(), vl::Has_GL_Version_2_0, vl::OpenGLContext::normal(), NULL, outlineColor(), outlineEnabled(), vl::Vector3< T_Scalar >::ptr(), vl::Vector4< T_Scalar >::ptr(), renderBackground(), renderBorder(), renderText(), shadowColor(), shadowEnabled(), shadowVector(), text(), and VL_CHECK.
void vl::Text::computeBounds_Implementation | ( | ) | [inline, virtual] |
Implements vl::Renderable.
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 812 of file Text.cpp.
References text().
Referenced by boundingRectTransformed().
Definition at line 817 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 894 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::Transform::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().
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 888 of file Text.cpp.
References boundingRectTransformed().
void Text::translate | ( | float | x, |
float | y, | ||
float | z | ||
) |
Definition at line 1007 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 1012 of file Text.cpp.
References mMatrix, and vl::Matrix4< T_Scalar >::rotate().
void Text::resetMatrix | ( | ) |
Definition at line 1017 of file Text.cpp.
References mMatrix, and vl::Matrix4< T_Scalar >::setIdentity().
virtual void vl::Text::updateDirtyBufferObject | ( | EBufferObjectUpdateMode | ) | [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.
virtual void vl::Text::deleteBufferObject | ( | ) | [inline, virtual] |
Destroys the BufferObject (vertex buffer objects) associated to this a Renderable.
Implements vl::Renderable.
void Text::renderText | ( | const Actor * | actor, |
const Camera * | camera, | ||
const fvec4 & | color, | ||
const fvec2 & | offset | ||
) | const [protected] |
Definition at line 145 of file Text.cpp.
References vl::Vector4< T_Scalar >::a(), vl::Glyph::advance(), vl::AlignBottom, vl::AlignHCenter, vl::AlignLeft, alignment(), vl::AlignRight, vl::AlignTop, vl::AlignVCenter, vl::Vector4< T_Scalar >::b(), backgroundEnabled(), borderEnabled(), vl::Matrix4< T_Scalar >::e(), vl::Log::error(), font(), vl::Vector4< T_Scalar >::g(), vl::Matrix4< float >::getOrtho(), vl::Glyph::glyphIndex(), vl::Glyph::height(), vl::Viewport::height(), kerningEnabled(), layout(), vl::Glyph::left(), vl::LeftToRightText, vl::String::length(), vl::length(), margin(), vl::AABB::maxCorner(), mFont, vl::AABB::minCorner(), mMatrix, mode(), vl::Camera::project(), vl::Vector4< T_Scalar >::ptr(), vl::Matrix4< T_Scalar >::ptr(), vl::Vector4< T_Scalar >::r(), rawboundingRect(), vl::RightToLeftText, vl::Glyph::s0(), vl::Glyph::s1(), vl::Glyph::t0(), vl::Glyph::t1(), text(), vl::Text2D, vl::TextAlignCenter, vl::TextAlignJustify, vl::TextAlignLeft, textAlignment(), vl::TextAlignRight, vl::Glyph::textureHandle(), vl::Glyph::top(), vl::Actor::transform(), vl::Matrix4< T_Scalar >::translate(), vl::Camera::viewport(), viewportAlignment(), VL_CHECK, VL_CHECK_OGL, VL_TRAP, vl::Glyph::width(), vl::AABB::width(), vl::Viewport::width(), vl::Transform::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().
Definition at line 704 of file Text.cpp.
References vl::Vector4< T_Scalar >::a(), vl::Vector4< T_Scalar >::b(), boundingRectTransformed(), vl::Matrix4< T_Scalar >::e(), vl::Vector4< T_Scalar >::g(), vl::Matrix4< float >::getOrtho(), vl::Viewport::height(), mBackgroundColor, mode(), NULL, vl::Matrix4< T_Scalar >::ptr(), vl::Vector4< T_Scalar >::r(), vl::Text2D, vl::Camera::viewport(), VL_CHECK_OGL, vl::Viewport::width(), vl::Viewport::x(), and vl::Viewport::y().
Referenced by render_Implementation().
Definition at line 757 of file Text.cpp.
References vl::Vector4< T_Scalar >::a(), vl::Vector4< T_Scalar >::b(), boundingRectTransformed(), vl::Matrix4< T_Scalar >::e(), vl::Vector4< T_Scalar >::g(), vl::Matrix4< float >::getOrtho(), vl::Viewport::height(), mBorderColor, mode(), NULL, vl::Matrix4< T_Scalar >::ptr(), vl::Vector4< T_Scalar >::r(), vl::Text2D, vl::Camera::viewport(), VL_CHECK_OGL, vl::Viewport::width(), vl::Viewport::x(), and vl::Viewport::y().
Referenced by render_Implementation().
Definition at line 575 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, NULL, 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().
ref<Font> vl::Text::mFont [mutable, protected] |
Definition at line 150 of file Text.hpp.
Referenced by rawboundingRect(), and renderText().
String vl::Text::mText [protected] |
fvec4 vl::Text::mColor [protected] |
fvec4 vl::Text::mBorderColor [protected] |
Definition at line 153 of file Text.hpp.
Referenced by renderBorder().
fvec4 vl::Text::mBackgroundColor [protected] |
Definition at line 154 of file Text.hpp.
Referenced by renderBackground().
fvec4 vl::Text::mOutlineColor [protected] |
fvec4 vl::Text::mShadowColor [protected] |
fvec2 vl::Text::mShadowVector [protected] |
fmat4 vl::Text::mMatrix [protected] |
Definition at line 158 of file Text.hpp.
Referenced by boundingRectTransformed(), renderText(), resetMatrix(), rotate(), and translate().
float vl::Text::mInterlineSpacing [protected] |
int vl::Text::mAlignment [protected] |
int vl::Text::mViewportAlignment [protected] |
int vl::Text::mMargin [protected] |
ETextMode vl::Text::mMode [protected] |
ETextLayout vl::Text::mLayout [protected] |
ETextAlign vl::Text::mTextAlignment [protected] |
bool vl::Text::mBorderEnabled [protected] |
bool vl::Text::mBackgroundEnabled [protected] |
bool vl::Text::mOutlineEnabled [protected] |
bool vl::Text::mShadowEnabled [protected] |
bool vl::Text::mKerningEnabled [protected] |