diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-08 12:40:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-08 12:42:59 +0300 |
commit | 9d8aaf77ac2e43c29c4f9f8ef633b8b0e78bd1ea (patch) | |
tree | debf4fad4eede8e902a6b2fd97cbfb61d4a8d991 /source/gameengine | |
parent | d1d0f8eb1a7a7c13b57d57e5e94263b8e9d44faa (diff) |
Fix T45981: BGE, 2D filters leak memory
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index f1ce8356e20..cedc27c3b92 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -75,6 +75,12 @@ texturewidth(-1), textureheight(-1), RAS_2DFilterManager::~RAS_2DFilterManager() { FreeTextures(); + + for (int passindex = 0; passindex < MAX_RENDER_PASS; passindex++) { + if (m_filters[passindex]) { + glDeleteObjectARB(m_filters[passindex]); + } + } } void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *task, const char *code) @@ -119,11 +125,10 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success); - if (!success) - { + if (!success) { /*Shader Comile Error*/ PrintShaderErrors(fShader, "compile", shadersource); - return 0; + goto fail; } program = glCreateProgramObjectARB(); @@ -131,23 +136,37 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) glLinkProgramARB(program); glGetObjectParameterivARB(program, GL_LINK_STATUS, &success); - if (!success) - { + if (!success) { /*Program Link Error*/ PrintShaderErrors(fShader, "link", shadersource); - return 0; + goto fail; } glValidateProgramARB(program); glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success); - if (!success) - { + if (!success) { /*Program Validation Error*/ PrintShaderErrors(fShader, "validate", shadersource); - return 0; + goto fail; + } + + /* owned by 'program' */ + if (fShader) { + glDeleteObjectARB(fShader); } return program; + + +fail: + if (fShader) { + glDeleteObjectARB(fShader); + } + + if (program) { + glDeleteObjectARB(program); + } + return 0; } unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) |