50#ifndef ACG_TEXTNODE_HH
51#define ACG_TEXTNODE_HH
57#include "TransformNode.hh"
58#include "DrawModes.hh"
59#include <ACG/GL/IRenderer.hh>
60#include <ACG/GL/VertexDeclaration.hh>
63#include <QFontMetrics>
66#include <QOpenGLWidget>
105 const std::string& _name=
"<TextNode>",
106 TextMode _textMode = SCREEN_ALIGNED,
107 bool _alwaysOnTop =
false);
119 void boundingBox(
Vec3d& _bbMin,
Vec3d& _bbMax)
override;
137 void setRenderingMode(
TextMode _textMode);
140 void setAlwaysOnTop(
bool _alwaysOnTop);
149 void setText(std::string _text);
152 void setSize(
const double _size);
155 void setPixelSize(
const unsigned int _size);
158 void setFont(
const QFont& _font);
173 static void updateFont();
177 static quint32 nearestPowerOfTwo(quint32 num);
192 void applyScreenAligned(
GLState &_state);
198 static std::map< char, std::pair<unsigned int, unsigned int> > createMap();
261 static std::map< char, std::pair<unsigned int, unsigned int> >
charToIndex_;
280 static const int numberOfChars_ = 94;
283 static const unsigned int rows_ = 10;
286 static const unsigned int columns_ = 10;
bool cullFaceEnabled_
stores if GL_CULL_FACE was enabled on entering TextNode
std::vector< GLfloat > vertexBuffer_
buffer of vertex coordinates and texture coordinates of the quads
static QFont qfont_
font that is used to generate the texture in updateFont()
GLenum alphaTestFunc_
stores alpha test comparison function
bool blendEnabled_
stores if GL_BLEND was enabled on entering TextNode
float alphaTestValue_
stores the alpha value used for alpha test
TextMode textMode_
current display mode of text_ (SCREEN_ALIGNED, SCREEN_ALIGNED_STATIC_SIZE or OBJECT_ALIGNED)
static QFontMetrics fontMetric_
static GLuint texture_
handle for the texture into which characters from qfont_ are painted in updateFont()
static int imageHeight_
height of the generated texture
bool texture2dEnabled_
stores if GL_TEXTURE_2D was enabled on entering TextNode
@ SCREEN_ALIGNED_STATIC_SIZE
Text will always stay parallel to screen.
ACG_CLASSNAME(TextNode)
static name of this class
double size_
scaling factor by which the quads in vbo_ are scaled
unsigned pixelSize_
pixelSize of the text for the SCREEN_ALIGNED_STATIC_SIZE mode
static bool initialised_
this is used to ensure that the texture is only generated once when necessary
ACG::VertexDeclaration vertexDecl_
stores the vertex declaration
GLint blendDest_
stores the dfactor parameter of glBlendFunc on entering TextNode
bool depthEnabled_
stores if GL_DEPTH_TEST was enabled on entering TextNode
static QColor color_
color that is used to draw the characters into the texture in updateFont()
GLint blendSrc_
stores the sfactor parameter of glBlendFunc on entering TextNode
bool alphaTest_
stores if the alpha test was enabled
bool alwaysOnTop_
stores if text should be drawn always on top
float lastScale_
stores the last scaling factor the text computed to SCREEN_ALIGNED_STATIC_SIZE
float lastScale()
returns the scaling factor for screen aligned text the text. returns 0, if textmode is not SCREEN_ALI...
std::string text_
text to be displayed on quads in vbo_
static std::map< char, std::pair< unsigned int, unsigned int > > charToIndex_
maps most readable characters to indices for texture coordinate calculation in updateVBO()
static int imageWidth_
width of the generated texture
Class to define the vertex input layout.
Namespace providing different geometric functions concerning angles.