mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 23:09:35 +02:00
Fixed renderer related files memory wastes
This commit is contained in:
parent
688bc17954
commit
7688dc4779
4 changed files with 33 additions and 4 deletions
|
@ -97,6 +97,10 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Head::~Head() {
|
||||||
|
glDeleteTextures(1, &_irisTextureID);
|
||||||
|
}
|
||||||
|
|
||||||
void Head::init() {
|
void Head::init() {
|
||||||
if (!_irisProgramInitialized) {
|
if (!_irisProgramInitialized) {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ProgramObject;
|
||||||
class Head : public HeadData {
|
class Head : public HeadData {
|
||||||
public:
|
public:
|
||||||
Head(Avatar* owningAvatar);
|
Head(Avatar* owningAvatar);
|
||||||
|
~Head();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
@ -15,13 +15,28 @@
|
||||||
#include "ProgramObject.h"
|
#include "ProgramObject.h"
|
||||||
#include "RenderUtil.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 {
|
QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const {
|
||||||
return (_renderMode == DIFFUSE_ADD_MODE && !_isOddFrame) ?
|
return (_renderMode == DIFFUSE_ADD_MODE && !_isOddFrame) ?
|
||||||
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject() :
|
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject() :
|
||||||
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ProgramObject* createProgram(const QString& name) {
|
static ProgramObject* createProgram(const QString& name) {
|
||||||
|
@ -37,6 +52,11 @@ static ProgramObject* createProgram(const QString& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlowEffect::init() {
|
void GlowEffect::init() {
|
||||||
|
if (_initialized) {
|
||||||
|
qDebug("[ERROR] GlowEffeect is already initialized.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
|
|
||||||
_addProgram = createProgram("glow_add");
|
_addProgram = createProgram("glow_add");
|
||||||
|
@ -59,6 +79,8 @@ void GlowEffect::init() {
|
||||||
_diffuseProgram->release();
|
_diffuseProgram->release();
|
||||||
|
|
||||||
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
|
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlowEffect::prepare() {
|
void GlowEffect::prepare() {
|
||||||
|
|
|
@ -21,8 +21,8 @@ class GlowEffect : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GlowEffect();
|
GlowEffect();
|
||||||
|
~GlowEffect();
|
||||||
|
|
||||||
/// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state
|
/// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state
|
||||||
/// (either the secondary or the tertiary).
|
/// (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 };
|
enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, DIFFUSE_ADD_MODE, RENDER_MODE_COUNT };
|
||||||
|
|
||||||
|
bool _initialized;
|
||||||
|
|
||||||
RenderMode _renderMode;
|
RenderMode _renderMode;
|
||||||
ProgramObject* _addProgram;
|
ProgramObject* _addProgram;
|
||||||
ProgramObject* _horizontalBlurProgram;
|
ProgramObject* _horizontalBlurProgram;
|
||||||
|
|
Loading…
Reference in a new issue