Help those suffering in the Horn of Africa

Cleaning Up

Prev: The InfoLog Next: Comm. OpenGL => Shaders
 

In a previous subsection a function to attach a shader to a program was presented. A function to detach a shader from a program is also available.

The OpenGL 2.0 syntax is as follows:


void glDetachShader(GLuint program, GLuint shader);

Parameter:

  • program – The program to detach from.
  • shader – The shader to detach.

And the ARB extension syntax is:


void glDetachObjectARB(GLhandleARB program, GLhandleARB shader);

Parameter:

  • program – The program to detach from.
  • shader – The shader to detach.

Only shaders that are not attached can be deleted so this operation is not irrelevant. To delete a shader, or a program, in OpenGL 2.0, use the following functions:


void glDeleteShader(GLuint id);
void glDeleteProgram(GLuint id);

Parameter:

  • id – The handler of the shader or program to delete.

When using the ARB extensions, there is a single function to delete both shaders and programs:


void glDeleteObjectARB(GLhandleARB id);

Parameter:

  • id – The handler of the shader or program to delete.

In the case of a shader that is still attached to some (one or more) programs, the shader is not actually deleted, but only marked for deletion. The delete operation will only be concluded when the shader is no longer attached to any program, i.e. it has been detached from all programs it was attached to.

 

 

Prev: The InfoLog Next: Comm. OpenGL => Shaders
 

3 comments on “Cleaning Up

  1. blazt on said:

    You could include information that “marked for deletion” also works on program objects and that you disable a program with glUseProgram(0) or glUseProgram(some_other_program_handle).

    Other than that it’s a really good tutorial :) .

  2. AlexRNL on said:

    Thanks for your great tutorials, they have been very helpful in learning about shaders.

    Btw, i’ve noticed some typos in this article: “hanule(r)” -> “handle(r)” (5 times).

Leave a Reply

Your email address will not be published. Required fields are marked *

*

87,936 Spam Comments Blocked so far by Spam Free Wordpress

HTML tags are not allowed.

© 2013 Lighthouse3d.com Suffusion theme by Sayontan Sinha