mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:01:14 +02:00
Other TextRenderer memory leak
This commit is contained in:
parent
9a007ab135
commit
ee4b28b6b9
2 changed files with 6 additions and 5 deletions
|
@ -16,12 +16,10 @@
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <TextRenderer.h>
|
|
||||||
|
|
||||||
#include "RenderableTextEntityItem.h"
|
#include "RenderableTextEntityItem.h"
|
||||||
#include "GLMHelpers.h"
|
#include "GLMHelpers.h"
|
||||||
|
|
||||||
const int FIXED_FONT_POINT_SIZE = 40;
|
|
||||||
|
|
||||||
EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
return new RenderableTextEntityItem(entityID, 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<GeometryCache>()->renderQuad(topLeft, bottomRight, glm::vec4(toGlm(getBackgroundColorX()), alpha));
|
||||||
DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram();
|
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);
|
glTranslatef(-(halfDimensions.x - leftMargin), halfDimensions.y - topMargin, 0.0f);
|
||||||
glm::vec4 textColor(toGlm(getTextColorX()), alpha);
|
glm::vec4 textColor(toGlm(getTextColorX()), alpha);
|
||||||
// this is a ratio determined through experimentation
|
// this is a ratio determined through experimentation
|
||||||
const float scaleFactor = 0.08f * _lineHeight;
|
const float scaleFactor = 0.08f * _lineHeight;
|
||||||
glScalef(scaleFactor, -scaleFactor, scaleFactor);
|
glScalef(scaleFactor, -scaleFactor, scaleFactor);
|
||||||
glm::vec2 bounds(dimensions.x / scaleFactor, dimensions.y / 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();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#define hifi_RenderableTextEntityItem_h
|
#define hifi_RenderableTextEntityItem_h
|
||||||
|
|
||||||
#include <TextEntityItem.h>
|
#include <TextEntityItem.h>
|
||||||
|
#include <TextRenderer.h>
|
||||||
|
|
||||||
|
const int FIXED_FONT_POINT_SIZE = 40;
|
||||||
|
|
||||||
class RenderableTextEntityItem : public TextEntityItem {
|
class RenderableTextEntityItem : public TextEntityItem {
|
||||||
public:
|
public:
|
||||||
|
@ -21,10 +24,12 @@ public:
|
||||||
RenderableTextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
RenderableTextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||||
TextEntityItem(entityItemID, properties)
|
TextEntityItem(entityItemID, properties)
|
||||||
{ }
|
{ }
|
||||||
|
~RenderableTextEntityItem() { delete _textRenderer; }
|
||||||
|
|
||||||
virtual void render(RenderArgs* args);
|
virtual void render(RenderArgs* args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue