Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deconstructor to delete the shader program resource #370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added includes/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions includes/learnopengl/shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class Shader
glDeleteShader(geometry);

}
// free the shader resource
// ------------------------------------------------------------------------
~Shader()
{
glDeleteProgram(ID);
}
// activate the shader
// ------------------------------------------------------------------------
void use()
Expand Down
6 changes: 6 additions & 0 deletions includes/learnopengl/shader_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class ComputeShader
// delete the shaders as they're linked into our program now and no longer necessary
glDeleteShader(compute);
}

// free the shader resource
~ComputeShader()
{
glDeleteProgram(ID);
}
// activate the shader
// ------------------------------------------------------------------------
void use()
Expand Down
6 changes: 6 additions & 0 deletions includes/learnopengl/shader_m.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class Shader
glDeleteShader(fragment);

}
// free the shader resource
// ------------------------------------------------------------------------
~Shader()
{
glDeleteProgram(ID);
}
// activate the shader
// ------------------------------------------------------------------------
void use() const
Expand Down
7 changes: 6 additions & 1 deletion includes/learnopengl/shader_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ class Shader
glDeleteShader(vertex);
glDeleteShader(fragment);
}
// activate the shader
// free the shader resource
// ------------------------------------------------------------------------
~Shader()
{
glDeleteProgram(ID);
} // activate the shader
// ------------------------------------------------------------------------
void use()
{
Expand Down
7 changes: 6 additions & 1 deletion includes/learnopengl/shader_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ class Shader
glDeleteShader(fragment);
if(geometryPath != nullptr)
glDeleteShader(geometry);

}
// free the shader resource
// ------------------------------------------------------------------------
~Shader()
{
glDeleteProgram(ID);
}
// activate the shader
// ------------------------------------------------------------------------
Expand Down