Other TextRenderer memory leak

This commit is contained in:
Atlante45 2015-05-20 16:54:39 +02:00
parent 9a007ab135
commit ee4b28b6b9
2 changed files with 6 additions and 5 deletions

View file

@ -16,12 +16,10 @@
#include <DeferredLightingEffect.h>
#include <GeometryCache.h>
#include <PerfStat.h>
#include <TextRenderer.h>
#include "RenderableTextEntityItem.h"
#include "GLMHelpers.h"
const int FIXED_FONT_POINT_SIZE = 40;
EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableTextEntityItem(entityID, properties);
@ -57,15 +55,13 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, glm::vec4(toGlm(getBackgroundColorX()), alpha));
DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
glTranslatef(-(halfDimensions.x - leftMargin), halfDimensions.y - topMargin, 0.0f);
glm::vec4 textColor(toGlm(getTextColorX()), alpha);
// this is a ratio determined through experimentation
const float scaleFactor = 0.08f * _lineHeight;
glScalef(scaleFactor, -scaleFactor, scaleFactor);
glm::vec2 bounds(dimensions.x / scaleFactor, dimensions.y / scaleFactor);
textRenderer->draw(0, 0, _text, textColor, bounds);
_textRenderer->draw(0, 0, _text, textColor, bounds);
}
glPopMatrix();
}

View file

@ -13,6 +13,9 @@
#define hifi_RenderableTextEntityItem_h
#include <TextEntityItem.h>
#include <TextRenderer.h>
const int FIXED_FONT_POINT_SIZE = 40;
class RenderableTextEntityItem : public TextEntityItem {
public:
@ -21,10 +24,12 @@ public:
RenderableTextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
TextEntityItem(entityItemID, properties)
{ }
~RenderableTextEntityItem() { delete _textRenderer; }
virtual void render(RenderArgs* args);
private:
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
};