Light | Dark



glDetachShader — Detaches a shader object from a program object to which it is attached

C Specification

void glDetachShader( GLuint program,
  GLuint shader);



Specifies the program object from which to detach the shader object.


Specifies the shader object to be detached.


glDetachShader detaches the shader object specified by shader from the program object specified by program. This command can be used to undo the effect of the command glAttachShader.

If shader has already been flagged for deletion by a call to glDeleteShader and it is not attached to any other program object, it will be deleted after it has been detached.


GL_INVALID_VALUE is generated if either program or shader is a value that was not generated by OpenGL.

GL_INVALID_OPERATION is generated if program is not a program object.

GL_INVALID_OPERATION is generated if shader is not a shader object.

GL_INVALID_OPERATION is generated if shader is not attached to program.

Associated Gets

glGetAttachedShaders with the handle of a valid program object

glGetShader with arguments shader and GL_DELETE_STATUS



Version Support

OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5
Think you can improve this page? Edit this page on GitHub.