NGL
6.5
The NCCA Graphics Library
|
#include <Text.h>
Public Member Functions | |
Text (const QFont &_f) noexcept | |
ctor must pass in a ready constructed QFont make sure the size and emphasis is set before doing this as you can't modify the font after construction and you will need a new Text class for each different type of text / font More... | |
~Text () | |
dtor will clean / remove textures and VAO's for the class More... | |
void | renderText (float _x, float _y, const QString &_text) const noexcept |
render the text to the screen at _x,_y where 0,0 is top left of the screen all positioning is relative to the screen size set with the setScreenSize method so it is important that changes in screen size are updated. These value will be sent to the nglTextShader to be rendered (see source ) More... | |
void | setScreenSize (int _w, int _h) noexcept |
set the size of the screen to scale our font to fit correctly this basically creates the orthographic projection needed for x/y assuming that the openGL window has 0,0 at the center and we use NDC co-ordinates -1 -> 1 in X and Y we then get x=(x*xScale)+xtran y=(y*yScale)+ytrans; to place the text in screen space More... | |
void | setColour (const Colour &_c) noexcept |
set the colour of the font from an Colour More... | |
void | setColour (Real _r, Real _g, Real _b) noexcept |
set the colour of the font from three floats as a convenience method More... | |
void | setTransform (float _x, float _y) noexcept |
Protected Attributes | |
QHash< char, FontChar > | m_characters |
a hash to store our FontChar data looked up by the char we want to render according to the Qt Docs a hash has faster lookups than QMap so using this More... | |
|
noexcept |
ctor must pass in a ready constructed QFont make sure the size and emphasis is set before doing this as you can't modify the font after construction and you will need a new Text class for each different type of text / font
[in] | _f | the font to use for drawing the text |
Definition at line 53 of file Text.cpp.
References ngl::AbstractVAO::bind(), ngl::VAOFactory::createVAO(), GL_FLOAT, GL_LINEAR, GL_NEAREST_MIPMAP_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, GL_UNSIGNED_BYTE, glBindTexture(), glGenerateMipmap, glGenTextures(), glTexImage2D(), glTexParameteri(), std::move(), ngl::nearestPowerOfTwo(), ngl::AbstractVAO::setData(), ngl::AbstractVAO::setNumIndices(), ngl::AbstractVAO::setVertexAttributePointer(), ngl::FontChar::textureID, ngl::AbstractVAO::unbind(), ngl::FontChar::vao, and ngl::FontChar::width.
ngl::Text::~Text | ( | ) |
dtor will clean / remove textures and VAO's for the class
Definition at line 250 of file Text.cpp.
References glDeleteTextures().
|
noexcept |
render the text to the screen at _x,_y where 0,0 is top left of the screen all positioning is relative to the screen size set with the setScreenSize method so it is important that changes in screen size are updated. These value will be sent to the nglTextShader to be rendered (see source )
[in] | _x | the x position of the text in screen space |
[in] | _y | the y position of the text in screen space |
[in] | _text | the text to draw (this is limited to ASCII chars ' '->'~' at present but unicode will be done soon |
Definition at line 265 of file Text.cpp.
References ngl::AbstractVAO::bind(), ngl::AbstractVAO::draw(), GL_BLEND, GL_DEPTH_TEST, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_TEXTURE0, GL_TEXTURE_2D, glActiveTexture, glBindTexture(), glBlendFunc(), glDisable(), glEnable(), ngl::Singleton< ShaderLib >::instance(), ngl::ShaderLib::setRegisteredUniform1f(), ngl::FontChar::textureID, ngl::AbstractVAO::unbind(), ngl::FontChar::vao, and ngl::FontChar::width.
set the colour of the font from an Colour
[in] | _c | the colour to set for the font (alpha is overridden by the texture) |
Definition at line 340 of file Text.cpp.
References ngl::Singleton< ShaderLib >::instance(), and ngl::ShaderLib::setRegisteredUniform3f().
set the colour of the font from three floats as a convenience method
[in] | _r | the red component of the colour for the font |
[in] | _g | the green component of the colour for the font |
[in] | _b | the blue component of the colour for the font |
Definition at line 352 of file Text.cpp.
References ngl::Singleton< ShaderLib >::instance(), and ngl::ShaderLib::setRegisteredUniform3f().
set the size of the screen to scale our font to fit correctly this basically creates the orthographic projection needed for x/y assuming that the openGL window has 0,0 at the center and we use NDC co-ordinates -1 -> 1 in X and Y we then get x=(x*xScale)+xtran y=(y*yScale)+ytrans; to place the text in screen space
[in] | _w | the current width of the screen |
[in] | _h | the current height of the screen |
Definition at line 314 of file Text.cpp.
References ngl::Singleton< ShaderLib >::instance(), and ngl::ShaderLib::setRegisteredUniform1f().
|
noexcept |
Definition at line 361 of file Text.cpp.
References ngl::Singleton< ShaderLib >::instance(), and ngl::ShaderLib::setRegisteredUniform2f().
|
protected |