Working on text rendering refactor

This commit is contained in:
Brad Davis 2015-02-03 18:57:39 -08:00
parent d64e7c464a
commit 0c78af9abb
4 changed files with 9 additions and 8 deletions

View file

@ -96,7 +96,7 @@ static TextRenderer* textRenderer(int mono) {
}
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,

View file

@ -108,7 +108,7 @@ void Text3DOverlay::render(RenderArgs* args) {
// Same font properties as textSize()
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;
@ -125,7 +125,7 @@ void Text3DOverlay::render(RenderArgs* args) {
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() };
textRenderer->drawString(0, 0, _text, textColor);
textRenderer->draw(0, 0, _text, textColor);
glDisable(GL_CLIP_PLANE0);
glDisable(GL_CLIP_PLANE1);

View file

@ -61,7 +61,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
// Same font properties as textSize()
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;

View file

@ -680,10 +680,11 @@ EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id)
void EntityTreeElement::cleanupEntities() {
uint16_t numberOfEntities = _entityItems->size();
for (uint16_t i = 0; i < numberOfEntities; i++) {
EntityItem* entity = (*_entityItems)[i];
entity->_element = NULL;
delete entity;
QList<EntityItem*> entitiesToDelete = *_entityItems;
foreach(EntityItem* entity, entitiesToDelete) {
entity->_element = NULL;
delete entity;
assert(_entityItems->size() == entitiesToDelete.size());
}
_entityItems->clear();
}