From 37442db20ee9ad03960d5bf337efb5716cc28985 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 11 Aug 2022 20:33:35 +0200 Subject: [PATCH] destroy program in shader destructor --- src/render/Shader.cpp | 7 +++++++ src/render/Shader.hpp | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/render/Shader.cpp b/src/render/Shader.cpp index 96b3caf7..d3f2afb2 100644 --- a/src/render/Shader.cpp +++ b/src/render/Shader.cpp @@ -10,4 +10,11 @@ GLint CShader::getUniformLocation(const std::string& unif) { } return itpos->second; +} + +CShader::~CShader() { + // destroy shader + if (program != 0) { + glDeleteProgram(program); + } } \ No newline at end of file diff --git a/src/render/Shader.hpp b/src/render/Shader.hpp index 3d3b3ddb..fc06d68b 100644 --- a/src/render/Shader.hpp +++ b/src/render/Shader.hpp @@ -5,7 +5,9 @@ class CShader { public: - GLuint program; + ~CShader(); + + GLuint program = 0; GLint proj; GLint color; GLint tex;