Visualization Library 2.0.0-b3

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vl::Text Class Reference

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

#include <Text.hpp>

+ Inheritance diagram for vl::Text:

Public Member Functions

 Text ()
 
const Stringtext () const
 
void setText (const String &text)
 
const fvec4color () const
 
void setColor (const fvec4 &color)
 
const fvec4borderColor () const
 
void setBorderColor (const fvec4 &border_color)
 
const fvec4outlineColor () const
 
void setOutlineColor (const fvec4 &outline_color)
 
const fvec4backgroundColor () const
 
void setBackgroundColor (const fvec4 &background_color)
 
const fvec4shadowColor () const
 
void setShadowColor (const fvec4 &shadow_color)
 
const fvec2shadowVector () const
 
void setShadowVector (const fvec2 &shadow_vector)
 
int margin () const
 
void setMargin (int margin)
 
const Fontfont () const
 
Fontfont ()
 
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. More...
 
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. More...
 
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. More...
 
virtual void deleteBufferObject ()
 Destroys the BufferObject (vertex buffer objects) associated to this a Renderable. More...
 
- Public Member Functions inherited from vl::Renderable
 Renderable ()
 Constructor. More...
 
virtual ~Renderable ()
 Destructor. More...
 
void render (const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context)
 Renders the Renderable and if necessary compiles the display list and updates the BufferObjects. More...
 
void computeBounds ()
 Recomputes the bounding box and bounding sphere of a Renderable. More...
 
long long boundsUpdateTick () const
 Returns the bounds-update-tick which is a counter incremented every time the bounding box or bounding sphere is updated. More...
 
void setBoundsDirty (bool dirty)
 Marks the bounding box and bounding sphere as dirty in order to be recomputed at the next rendering. More...
 
bool boundsDirty () const
 Returns whether the bounding sphere or bounding box are "dirty", that is, meant to be recomputed. More...
 
void setBoundingBox (const AABB &aabb)
 Sets the bounding box of a Renderable. More...
 
void setBoundingSphere (const Sphere &sphere)
 Sets the bounding sphere of a Renderable. More...
 
const AABBboundingBox () const
 Returns the bounding box of a Renderable without recomputing the bounds if dirty. More...
 
const SphereboundingSphere () const
 Returns the bounding sphere of a Renderable without recomputing the bounds if dirty. More...
 
const AABBboundingBox ()
 Returns the bounding box of a Renderable recomputing the bounds if dirty. More...
 
const SphereboundingSphere ()
 Returns the bounding sphere of a Renderable recomputing the bounds if dirty. More...
 
unsigned int displayList () const
 Returns the display list associated to a Renderable or 0 (zero) if no display list is associated. More...
 
void setDisplayList (unsigned int disp_list)
 Manually assciates a display list to a Renderable (to be used with care). More...
 
bool isDisplayListEnabled () const
 Returns true if display lists are enabled for a Renderable (disabled by default). More...
 
void setDisplayListEnabled (bool enabled)
 Enable/disable display lists (disabled by default). More...
 
bool displayListDirty () const
 Whether the display list associated to a Renderable should be recompiled at the next rendering. More...
 
void setDisplayListDirty (bool dirty)
 Whether the display list associated to a Renderable should be recompiled at the next rendering. More...
 
bool isBufferObjectEnabled () const
 Returns true if BufferObject (vertex buffer object) are enabled for a Renderable (enabled by default). More...
 
void setBufferObjectEnabled (bool enabled)
 Enable/disable BufferObject (vertex buffer object) (enabled by default). More...
 
bool isBufferObjectDirty () const
 Whether BufferObjects associated to a Renderable should be recomputed on the next rendering. More...
 
void setBufferObjectDirty (bool dirty=true)
 Whether BufferObjects associated to a Renderable should be recomputed on the next rendering. More...
 
void deleteDisplayList ()
 Deletes the display list currently associated to a Renderable. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

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 Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

ref< FontmFont
 
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
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

A Renderable that renders text with a given Font.

See also

Definition at line 50 of file Text.hpp.

Constructor & Destructor Documentation

◆ Text()

vl::Text::Text ( )
inline

Definition at line 55 of file Text.hpp.

Member Function Documentation

◆ alignment()

int vl::Text::alignment ( ) const
inline

Definition at line 93 of file Text.hpp.

Referenced by boundingRect(), and renderText().

◆ backgroundColor()

const fvec4& vl::Text::backgroundColor ( ) const
inline

Definition at line 74 of file Text.hpp.

◆ backgroundEnabled()

bool vl::Text::backgroundEnabled ( ) const
inline

Definition at line 114 of file Text.hpp.

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

◆ borderColor()

const fvec4& vl::Text::borderColor ( ) const
inline

Definition at line 68 of file Text.hpp.

◆ borderEnabled()

bool vl::Text::borderEnabled ( ) const
inline

Definition at line 111 of file Text.hpp.

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

◆ boundingRect() [1/2]

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().

◆ boundingRect() [2/2]

AABB Text::boundingRect ( const String text) const

◆ boundingRectTransformed() [1/2]

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

◆ boundingRectTransformed() [2/2]

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 888 of file Text.cpp.

References boundingRectTransformed().

◆ color()

const fvec4& vl::Text::color ( ) const
inline

Definition at line 65 of file Text.hpp.

Referenced by render_Implementation().

◆ computeBounds_Implementation()

void vl::Text::computeBounds_Implementation ( )
inlinevirtual

Implements vl::Renderable.

Definition at line 127 of file Text.hpp.

References vl::degrees(), and NULL.

◆ deleteBufferObject()

virtual void vl::Text::deleteBufferObject ( )
inlinevirtual

Destroys the BufferObject (vertex buffer objects) associated to this a Renderable.

Note
This function does not touch the local (non GPU) data stored in the buffers associated to the vertex attributes and DrawCall.

Implements vl::Renderable.

Definition at line 141 of file Text.hpp.

◆ font() [1/2]

const Font* vl::Text::font ( ) const
inline

◆ font() [2/2]

Font* vl::Text::font ( )
inline

Definition at line 87 of file Text.hpp.

◆ interlineSpacing()

float vl::Text::interlineSpacing ( ) const
inline

Definition at line 99 of file Text.hpp.

◆ kerningEnabled()

bool vl::Text::kerningEnabled ( ) const
inline

Definition at line 117 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

◆ layout()

ETextLayout vl::Text::layout ( ) const
inline

Definition at line 105 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

◆ margin()

int vl::Text::margin ( ) const
inline

Definition at line 83 of file Text.hpp.

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

◆ matrix()

const fmat4 vl::Text::matrix ( ) const
inline

Definition at line 90 of file Text.hpp.

◆ mode()

ETextMode vl::Text::mode ( ) const
inline

Definition at line 102 of file Text.hpp.

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

◆ outlineColor()

const fvec4& vl::Text::outlineColor ( ) const
inline

Definition at line 71 of file Text.hpp.

Referenced by render_Implementation().

◆ outlineEnabled()

bool vl::Text::outlineEnabled ( ) const
inline

Definition at line 120 of file Text.hpp.

Referenced by render_Implementation().

◆ rawboundingRect()

AABB Text::rawboundingRect ( const String text) const
protected

◆ render_Implementation()

void Text::render_Implementation ( const Actor actor,
const Shader shader,
const Camera camera,
OpenGLContext gl_context 
) const
virtual

◆ renderBackground()

void Text::renderBackground ( const Actor actor,
const Camera camera 
) const
protected

◆ renderBorder()

void Text::renderBorder ( const Actor actor,
const Camera camera 
) const
protected

◆ renderText()

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::Viewport::height(), vl::Glyph::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::Viewport::width(), vl::Glyph::width(), vl::AABB::width(), vl::Transform::worldMatrix(), vl::Viewport::x(), vl::Vector3< T_Scalar >::x(), vl::Vector4< T_Scalar >::x(), vl::Vector2< T_Scalar >::x(), vl::Viewport::y(), vl::Vector3< T_Scalar >::y(), vl::Vector4< T_Scalar >::y(), vl::Vector2< T_Scalar >::y(), vl::Vector3< T_Scalar >::z(), and vl::Vector4< T_Scalar >::z().

Referenced by render_Implementation().

◆ resetMatrix()

void Text::resetMatrix ( )

Definition at line 1017 of file Text.cpp.

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

◆ rotate()

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().

◆ setAlignment()

void vl::Text::setAlignment ( int  align)
inline

◆ setBackgroundColor()

void vl::Text::setBackgroundColor ( const fvec4 background_color)
inline

Definition at line 75 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setBackgroundEnabled()

void vl::Text::setBackgroundEnabled ( bool  background)
inline

Definition at line 115 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setBorderColor()

void vl::Text::setBorderColor ( const fvec4 border_color)
inline

Definition at line 69 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setBorderEnabled()

void vl::Text::setBorderEnabled ( bool  border)
inline

Definition at line 112 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setColor()

void vl::Text::setColor ( const fvec4 color)
inline

◆ setFont()

void vl::Text::setFont ( Font font)
inline

◆ setInterlineSpacing()

void vl::Text::setInterlineSpacing ( float  spacing)
inline

Definition at line 100 of file Text.hpp.

◆ setKerningEnabled()

void vl::Text::setKerningEnabled ( bool  kerning)
inline

Definition at line 118 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel().

◆ setLayout()

void vl::Text::setLayout ( ETextLayout  layout)
inline

Definition at line 106 of file Text.hpp.

◆ setMargin()

void vl::Text::setMargin ( int  margin)
inline

Definition at line 84 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setMatrix()

void vl::Text::setMatrix ( const fmat4 matrix)
inline

Definition at line 91 of file Text.hpp.

Referenced by vl::VectorGraphics::drawText(), and vl::VolumePlot::setupLabels().

◆ setMode()

void vl::Text::setMode ( ETextMode  mode)
inline

Definition at line 103 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel().

◆ setOutlineColor()

void vl::Text::setOutlineColor ( const fvec4 outline_color)
inline

Definition at line 72 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setOutlineEnabled()

void vl::Text::setOutlineEnabled ( bool  outline)
inline

Definition at line 121 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setShadowColor()

void vl::Text::setShadowColor ( const fvec4 shadow_color)
inline

Definition at line 78 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setShadowEnabled()

void vl::Text::setShadowEnabled ( bool  shadow)
inline

Definition at line 124 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setShadowVector()

void vl::Text::setShadowVector ( const fvec2 shadow_vector)
inline

Definition at line 81 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel(), and vl::VolumePlot::setupLabels().

◆ setText()

void vl::Text::setText ( const String text)
inline

◆ setTextAlignment()

void vl::Text::setTextAlignment ( ETextAlign  align)
inline

Definition at line 109 of file Text.hpp.

Referenced by vl::Molecule::generateAtomLabel().

◆ setViewportAlignment()

void vl::Text::setViewportAlignment ( int  align)
inline

Definition at line 97 of file Text.hpp.

Referenced by vl::VectorGraphics::drawText(), and vl::Molecule::generateAtomLabel().

◆ shadowColor()

const fvec4& vl::Text::shadowColor ( ) const
inline

Definition at line 77 of file Text.hpp.

Referenced by render_Implementation().

◆ shadowEnabled()

bool vl::Text::shadowEnabled ( ) const
inline

Definition at line 123 of file Text.hpp.

Referenced by render_Implementation().

◆ shadowVector()

const fvec2& vl::Text::shadowVector ( ) const
inline

Definition at line 80 of file Text.hpp.

Referenced by render_Implementation().

◆ text()

const String& vl::Text::text ( ) const
inline

Definition at line 62 of file Text.hpp.

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

◆ textAlignment()

ETextAlign vl::Text::textAlignment ( ) const
inline

Definition at line 108 of file Text.hpp.

Referenced by renderText().

◆ translate()

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().

◆ updateDirtyBufferObject()

virtual void vl::Text::updateDirtyBufferObject ( EBufferObjectUpdateMode  )
inlinevirtual

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 139 of file Text.hpp.

◆ viewportAlignment()

int vl::Text::viewportAlignment ( ) const
inline

Definition at line 96 of file Text.hpp.

Referenced by boundingRectTransformed(), and renderText().

Member Data Documentation

◆ mAlignment

int vl::Text::mAlignment
protected

Definition at line 160 of file Text.hpp.

◆ mBackgroundColor

fvec4 vl::Text::mBackgroundColor
protected

Definition at line 154 of file Text.hpp.

Referenced by renderBackground().

◆ mBackgroundEnabled

bool vl::Text::mBackgroundEnabled
protected

Definition at line 167 of file Text.hpp.

◆ mBorderColor

fvec4 vl::Text::mBorderColor
protected

Definition at line 153 of file Text.hpp.

Referenced by renderBorder().

◆ mBorderEnabled

bool vl::Text::mBorderEnabled
protected

Definition at line 166 of file Text.hpp.

◆ mColor

fvec4 vl::Text::mColor
protected

Definition at line 152 of file Text.hpp.

◆ mFont

ref<Font> vl::Text::mFont
mutableprotected

Definition at line 150 of file Text.hpp.

Referenced by rawboundingRect(), and renderText().

◆ mInterlineSpacing

float vl::Text::mInterlineSpacing
protected

Definition at line 159 of file Text.hpp.

◆ mKerningEnabled

bool vl::Text::mKerningEnabled
protected

Definition at line 170 of file Text.hpp.

◆ mLayout

ETextLayout vl::Text::mLayout
protected

Definition at line 164 of file Text.hpp.

◆ mMargin

int vl::Text::mMargin
protected

Definition at line 162 of file Text.hpp.

◆ mMatrix

fmat4 vl::Text::mMatrix
protected

Definition at line 158 of file Text.hpp.

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

◆ mMode

ETextMode vl::Text::mMode
protected

Definition at line 163 of file Text.hpp.

◆ mOutlineColor

fvec4 vl::Text::mOutlineColor
protected

Definition at line 155 of file Text.hpp.

◆ mOutlineEnabled

bool vl::Text::mOutlineEnabled
protected

Definition at line 168 of file Text.hpp.

◆ mShadowColor

fvec4 vl::Text::mShadowColor
protected

Definition at line 156 of file Text.hpp.

◆ mShadowEnabled

bool vl::Text::mShadowEnabled
protected

Definition at line 169 of file Text.hpp.

◆ mShadowVector

fvec2 vl::Text::mShadowVector
protected

Definition at line 157 of file Text.hpp.

◆ mText

String vl::Text::mText
protected

Definition at line 151 of file Text.hpp.

◆ mTextAlignment

ETextAlign vl::Text::mTextAlignment
protected

Definition at line 165 of file Text.hpp.

◆ mViewportAlignment

int vl::Text::mViewportAlignment
protected

Definition at line 161 of file Text.hpp.


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