mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 15:42:57 +02:00
Working on text rendering refactor
This commit is contained in:
parent
d64e7c464a
commit
0c78af9abb
4 changed files with 9 additions and 8 deletions
|
@ -96,7 +96,7 @@ static TextRenderer* textRenderer(int mono) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int widthText(float scale, int mono, char const* string) {
|
int widthText(float scale, int mono, char const* string) {
|
||||||
return textRenderer(mono)->computeWidth(string) * (scale / 0.10);
|
return textRenderer(mono)->computeExtent(string).x; // computeWidth(string) * (scale / 0.10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawText(int x, int y, float scale, float radians, int mono,
|
void drawText(int x, int y, float scale, float radians, int mono,
|
||||||
|
|
|
@ -108,7 +108,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
// Same font properties as textSize()
|
// Same font properties as textSize()
|
||||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
||||||
float maxHeight = (float)textRenderer->calculateHeight("Xy") * LINE_SCALE_RATIO;
|
float maxHeight = (float)textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||||
|
|
||||||
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
||||||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||||
|
|
||||||
glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
|
glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
|
||||||
textRenderer->drawString(0, 0, _text, textColor);
|
textRenderer->draw(0, 0, _text, textColor);
|
||||||
|
|
||||||
glDisable(GL_CLIP_PLANE0);
|
glDisable(GL_CLIP_PLANE0);
|
||||||
glDisable(GL_CLIP_PLANE1);
|
glDisable(GL_CLIP_PLANE1);
|
||||||
|
|
|
@ -61,7 +61,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
||||||
|
|
||||||
// Same font properties as textSize()
|
// Same font properties as textSize()
|
||||||
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE);
|
||||||
float maxHeight = (float)textRenderer->calculateHeight("Xy") * LINE_SCALE_RATIO;
|
float maxHeight = (float)textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO;
|
||||||
|
|
||||||
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
|
||||||
|
|
||||||
|
|
|
@ -680,10 +680,11 @@ EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id)
|
||||||
|
|
||||||
void EntityTreeElement::cleanupEntities() {
|
void EntityTreeElement::cleanupEntities() {
|
||||||
uint16_t numberOfEntities = _entityItems->size();
|
uint16_t numberOfEntities = _entityItems->size();
|
||||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
QList<EntityItem*> entitiesToDelete = *_entityItems;
|
||||||
EntityItem* entity = (*_entityItems)[i];
|
foreach(EntityItem* entity, entitiesToDelete) {
|
||||||
entity->_element = NULL;
|
entity->_element = NULL;
|
||||||
delete entity;
|
delete entity;
|
||||||
|
assert(_entityItems->size() == entitiesToDelete.size());
|
||||||
}
|
}
|
||||||
_entityItems->clear();
|
_entityItems->clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue