 |
BARE2D
|
|
Go to the documentation of this file.
6 std::string& vertShader,
7 unsigned int perspectiveWidth,
8 unsigned int perspectiveHeight)
9 :
BasicRenderer(fragShader, vertShader, perspectiveWidth, perspectiveHeight)
25 glm::vec2 newPosition = destRect;
28 newPosition -= font.
measure(text).x * scaling.x / 2.0f;
31 newPosition += font.
measure(text).x * scaling.x;
35 for(
int characterIndex = 0; text[characterIndex] != 0; characterIndex++)
37 char c = text[characterIndex];
42 newPosition.y += font.
getHeight() * scaling.y;
44 newPosition.x = destRect.x;
49 if(glyphIndex < 0 || (
unsigned int)glyphIndex > font.
getCharacters())
59 glm::vec4 updatedDestRect(newPosition, glyph->
size * scaling);
60 glm::vec4 uvRectFinal(glyph->
uvRect.x + uvRect.x * glyph->
uvRect.z,
62 glyph->
uvRect.w * uvRect.w);
68 newPosition.x += glyph->
size.x * scaling.x;
Essentially just a wrapper for the SDL TTF_Font type.
#define FIRST_PRINTABLE_CHAR
virtual void draw(Font &font, glm::vec2 scaling, glm::vec4 destRect, const char *text, float depth, Colour tint, Justification just=Justification::LEFT, glm::vec4 uvRect=glm::vec4(0.0f, 0.0f, 1.0f, 1.0f))
unsigned int getCharacters() const
CharacterGlyph * getGlyph(int &index)
Gets a character glyph. Does no checking to make sure it exists!
Represents a render glyph, modified for fonts!
An enum for text justification.
FontRenderer(std::string &fragShader, std::string &vertShader, unsigned int perspectiveWidth=2, unsigned int perspectiveHeight=2)
GLuint getTextureID() const
glm::vec2 measure(const char *s)
Measures the dimensions of some given text.
unsigned int getHeight() const
An RGBA 8-bit colour value.
virtual void draw(glm::vec4 destRect, glm::vec4 uvRect, GLuint texture, float depth, Colour colour=Colour(255, 255, 255, 255), float angle=0.0f, glm::vec2 COR=glm::vec2(0.5f))