public void Dispose() { if (ProgramID != 0) { // Make sure this program isn't being used if (Gl.CurrentProgram == ProgramID) { Gl.UseProgram(0); } Gl.DetachShader(ProgramID, VertexShader.ShaderID); Gl.DetachShader(ProgramID, FragmentShader.ShaderID); Gl.DeleteProgram(ProgramID); if (DisposeChildren) { VertexShader.Dispose(); FragmentShader.Dispose(); } this.ProgramID = 0; } }