Fixed renderer related files memory wastes

This commit is contained in:
atlante45 2013-09-03 13:50:01 -07:00
parent 688bc17954
commit 7688dc4779
4 changed files with 33 additions and 4 deletions

View file

@ -97,6 +97,10 @@ Head::Head(Avatar* owningAvatar) :
}
}
Head::~Head() {
glDeleteTextures(1, &_irisTextureID);
}
void Head::init() {
if (!_irisProgramInitialized) {
switchToResourcesParentIfRequired();

View file

@ -38,6 +38,7 @@ class ProgramObject;
class Head : public HeadData {
public:
Head(Avatar* owningAvatar);
~Head();
void init();
void reset();

View file

@ -15,13 +15,28 @@
#include "ProgramObject.h"
#include "RenderUtil.h"
GlowEffect::GlowEffect() : _renderMode(DIFFUSE_ADD_MODE), _isOddFrame(false), _intensity(0.0f) {
GlowEffect::GlowEffect()
: _initialized(false),
_renderMode(DIFFUSE_ADD_MODE),
_isOddFrame(false),
_intensity(0.0f) {
}
GlowEffect::~GlowEffect() {
if (_initialized) {
delete _addProgram;
delete _horizontalBlurProgram;
delete _verticalBlurAddProgram;
delete _verticalBlurProgram;
delete _addSeparateProgram;
delete _diffuseProgram;
}
}
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
return (_renderMode == DIFFUSE_ADD_MODE && !_isOddFrame) ?
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject() :
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject() :
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
}
static ProgramObject* createProgram(const QString& name) {
@ -37,6 +52,11 @@ static ProgramObject* createProgram(const QString& name) {
}
void GlowEffect::init() {
if (_initialized) {
qDebug("[ERROR] GlowEffeect is already initialized.\n");
return;
}
switchToResourcesParentIfRequired();
_addProgram = createProgram("glow_add");
@ -59,6 +79,8 @@ void GlowEffect::init() {
_diffuseProgram->release();
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
_initialized = true;
}
void GlowEffect::prepare() {

View file

@ -21,8 +21,8 @@ class GlowEffect : public QObject {
Q_OBJECT
public:
GlowEffect();
~GlowEffect();
/// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state
/// (either the secondary or the tertiary).
@ -53,6 +53,8 @@ private:
enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, DIFFUSE_ADD_MODE, RENDER_MODE_COUNT };
bool _initialized;
RenderMode _renderMode;
ProgramObject* _addProgram;
ProgramObject* _horizontalBlurProgram;