[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
According to this:
http://stackoverflow.com/questions/9113154/proper-way-to-delete-glsl-shader
We should be detaching and deleting shaders right after linking. I've got a
patch,
but wanted to run it by the list in case anyone sees a problem with this.
diff --git a/src/opengl/ogl_shader.c b/src/opengl/ogl_shader.c
index c5f9ddc..fdf6eb1 100644
--- a/src/opengl/ogl_shader.c
+++ b/src/opengl/ogl_shader.c
@@ -84,20 +84,6 @@ static bool glsl_attach_shader_source(ALLEGRO_SHADER
*shader,
ASSERT(display->flags & ALLEGRO_OPENGL);
if (source == NULL) {
- if (type == ALLEGRO_VERTEX_SHADER) {
- if (gl_shader->vertex_shader) {
- glDetachShader(gl_shader->program_object,
gl_shader->vertex_shader);
- glDeleteShader(gl_shader->vertex_shader);
- gl_shader->vertex_shader = 0;
- }
- }
- else {
- if (gl_shader->pixel_shader) {
- glDetachShader(gl_shader->program_object,
gl_shader->pixel_shader);
- glDeleteShader(gl_shader->pixel_shader);
- gl_shader->pixel_shader = 0;
- }
- }
return true;
}
else {
@@ -177,6 +163,17 @@ static bool glsl_build_shader(ALLEGRO_SHADER *shader)
return false;
}
+ if (gl_shader->vertex_shader) {
+ glDetachShader(gl_shader->program_object, gl_shader->vertex_shader);
+ glDeleteShader(gl_shader->vertex_shader);
+ gl_shader->vertex_shader = 0;
+ }
+ if (gl_shader->pixel_shader) {
+ glDetachShader(gl_shader->program_object, gl_shader->pixel_shader);
+ glDeleteShader(gl_shader->pixel_shader);
+ gl_shader->pixel_shader = 0;
+ }
+
/* Look up variable locations. */
lookup_varlocs(&gl_shader->varlocs, gl_shader->program_object);
@@ -238,8 +235,6 @@ static void glsl_destroy_shader(ALLEGRO_SHADER *shader)
{
ALLEGRO_SHADER_GLSL_S *gl_shader = (ALLEGRO_SHADER_GLSL_S *)shader;
- glDeleteShader(gl_shader->vertex_shader);
- glDeleteShader(gl_shader->pixel_shader);
glDeleteProgram(gl_shader->program_object);
al_free(shader);
}